2016-11-07 82 views
0

我需要在每個SOAP組件中放置一個xmlns,並且還要包含在SOAP正文中的數據模型,但是當我僅將ns包含在XmlElement名稱中時,正常工作,謝謝。d2LogicalModel上的XML名稱空間前綴d2lm未使用jaxb定義

SOAP主體:

package soap; 

import eu.datex2.schema._2_0._2_3.D2LogicalModel; 

import javax.xml.bind.annotation.XmlAccessType; 
import javax.xml.bind.annotation.XmlAccessorType; 
import javax.xml.bind.annotation.XmlElement; 
import javax.xml.bind.annotation.XmlType; 

    @XmlType(name = "body", propOrder = { 
     "soapBody" 
}) 
@XmlAccessorType(XmlAccessType.FIELD) 
public class Body { 

    @XmlElement(name="d2lm:d2LogicalModel") 
    private D2LogicalModel soapBody; 

    public Body() { 
     this.soapBody = new D2LogicalModel(); 
    } 

    public D2LogicalModel getSoapBody() { 
     return this.soapBody; 
    } 

    public void setSoapBody(D2LogicalModel soapBody) { 
     this.soapBody = soapBody; 
    } 
} 

SOAP標頭:

包皁;

import eu.datex2.schema._2_0._2_3.D2LogicalModel; 

import javax.xml.bind.annotation.*; 

@XmlType(name = "envelope", propOrder = { 
     "soapEnv", 
     "soapHeader", 
     "body" 
}) 
@XmlRootElement(name = "soapenv:Envelope") 
@XmlAccessorType(XmlAccessType.FIELD) 

public class Envelope { 

    @XmlAttribute(name="xmlns:soapenv") 
    private String soapEnvEncodingStyle; 

    @XmlAttribute(name="xmlns:env") 
    private String soapEnv; 

    @XmlElement(name="soapenv:Header") 
    private String soapHeader; 

    @XmlAttribute(name="xmlns:xdt") 
    private String soapXdt; 

    @XmlAttribute(name="xmlns:xsd") 
    private String soapXsd; 

    @XmlAttribute(name="env:schemaLocation") 
    private String schemaLocation; 

    @XmlElement(name="soapenv:Body") 
    private Body body; 



    public Envelope(){ 

     this.soapEnvEncodingStyle = "http://schemas/xmlsoap.org/soap/envelope/"; 
     this.soapEnv = "http://www.w3.org/2001/XMLSchema-instance"; 
     this.soapXdt = "http://www.w3.org/2004/07/xpath-datatypes"; 
     this.soapXsd = "http://www.w3.org/2001/XMLSchema"; 
     this.schemaLocation = "http://schemas/xmlsoap.org/soap/envelope/"; 
     this.soapHeader = new String(); 
     this.body = new Body(); 
    } 

    public Body getSoapBody() { 
     return this.body; 
    } 

    public void setBody(Body soapBody) { 
     this.body = soapBody; 
    } 
} 

回答

0

如果我刪除前綴d2lm它的作品,感謝