春天ws肥皂客户端+ jaxb2 [英] spring ws soap client+jaxb2

查看:87
本文介绍了春天ws肥皂客户端+ jaxb2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using the JAXb2 maven plugin to create the domain[bean ]classes.

当我尝试通过WebServiceTemplate类访问服务时,我收到以下错误。

When i try to hit the service thru WebServiceTemplate class, I am getting below error.

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>

我的绑定文件如下所示。

and my bindings file looks as follows.

我想知道它是如何期待三个元素的,最后一个元素与这个webservice完全没有关系,也没有在jaxb绑定文件中定义。我检查了创建的bean类,它们并不相互关联。

I am wondering how is it expecting three elements, that too the last one is not at all related with this webservice and not defined in jaxb binding file also. I have checked the created bean classes and they are not interrelated.

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

请注意这一点。我被困在这里。

Please throw some light on this. I am stuck here.

客户代码:

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

========

spring客户端代码:

spring client code:

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


推荐答案

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

How do you create your JAXBContext? Please show the Spring configuration.

错误消息也很奇怪:

。 ..unexpected元素(uri:http://services.abc.cde.efg.com,local:xxxLookupResponse)。预期的元素是......< {services.abc.cde.efg.com} xxxxxLookupResponse> ...

你有吗?在这里匹配名称( xxxLookupResponse xxxxxLookupResponse )?

Do you have matching names (xxxLookupResponse vs. xxxxxLookupResponse) here?

我的理论是你在两个地方生成或定义了一个包( services.abc.cde.efg.com ),JAXB选错了。

My theory is that you have one package (services.abc.cde.efg.com) generated or defined in two places and JAXB is picking the wrong one.

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

The binding files you refer to are not directly considered by JAXB, they are only used during the code generation. JAXB works with the generated classes then.

这篇关于春天ws肥皂客户端+ jaxb2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆