d2LogicalModel上的XML命名空间前缀d2lm未使用jaxb定义

时间:2016-11-07 10:57:33

标签: java xml soap jaxb

我需要在每个SOAP组件中放置一个xmlns,并且还需要在SOAP主体中包含数据模型,但是当我只是在XmlElement名称中包含ns时,它无法正常工作,谢谢。

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;
    }
}

1 个答案:

答案 0 :(得分:0)

如果我删除前缀 d2lm ,它可以正常工作,谢谢