繁体   English   中英

春季WS肥皂客户端+ JAXB2

[英]spring ws soap client+jaxb2

我正在使用JAXb2 maven插件来创建domain [bean]类。

当我尝试通过WebServiceTemplate类访问该服务时,出现以下错误。

Exception:org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://services.abc.cde.efg.com", local:"xxxLookupResponse"). Expected elements are <{services.abc.cde.efg.com"}xxxLookupRequest>,<{services.abc.cde.efg.com"}xxxLookupResponse>,<{services.abc.cde.efg.com"}zzzUploadOrder>

和我的绑定文件如下所示。

我想知道它如何期望三个元素,即最后一个也与该Web服务完全无关,也没有在jaxb绑定文件中定义。 我已经检查了创建的bean类,并且它们没有相互关联。

<jaxb:bindings schemaLocation="abcsServices.xsd" node="/xs:schema">
        <jaxb:bindings node="xs:complexType[@name='xxxxxLookupRequest']">
            <annox:annotate>
                <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                    name="xxxxxxLookupRequest" />
            </annox:annotate>
        </jaxb:bindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="abcsServices.xsd" node="/xs:schema">
        <jaxb:bindings node="xs:complexType[@name='xxxxxLookupResponse']">
            <annox:annotate>
                <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                    name="xxxxxLookupResponse" />
            </annox:annotate>
        </jaxb:bindings>
    </jaxb:bindings>

请对此加以说明。 我被困在这里。

客户代码:

ObjectFactory objFactory = new ObjectFactory(); xxxxLookupRequest req = objFactory.createxxxxLookupRequest(); req.setxxxx("12344"); req.setxxxxx("34234"); xxxxxLookupResponse response = (xxxxxLookupResponse) xxxxClient .doDeliveryLookUp(req); 

========

春季客户代码:

response = (xxxxxLookupResponse) getWebServiceTemplate() .marshalSendAndReceive(xxxxLookupRequest, new SoapActionCallback("urn:xxxxxLookup")); 

如何创建JAXBContext? 请显示Spring配置。

错误消息也很奇怪:

...unexpected element (uri:"http://services.abc.cde.efg.com", local:"xxxLookupResponse"). Expected elements are ... <{services.abc.cde.efg.com"}xxxxxLookupResponse>...

您在这里有匹配的名称( xxxLookupResponsexxxxxLookupResponse )吗?

我的理论是,您在两个位置生成或定义了一个程序包( services.abc.cde.efg.com ),而JAXB选择的是错误的程序包。

JAXB不会直接考虑您引用的绑定文件,它们仅在代码生成期间使用。 然后,JAXB将与生成的类一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM