Apache 解组异常:驼峰soap解组错误意外元素
[com.sun.istack.SAXParseException2;行号:1;列号:1;意外元素(uri:,local:“custDetails”)。预期元素为,,,,] 问题陈述:Camel不希望收到custDetails(webmethod)和命名空间。Apache 解组异常:驼峰soap解组错误意外元素,apache,soap,apache-camel,spring-camel,cxf-codegen-plugin,Apache,Soap,Apache Camel,Spring Camel,Cxf Codegen Plugin,[com.sun.istack.SAXParseException2;行号:1;列号:1;意外元素(uri:,local:“custDetails”)。预期元素为,,,,] 问题陈述:Camel不希望收到custDetails(webmethod)和命名空间。 期望值:使用camel-soap将有效负载解组到soapJaxb开箱即用 使用maven-jaxb2-plugin为下面的xsd生成JAXB类。结果生成了三个带有注释的类——Customer.java、ObjectFactory、java
期望值:使用camel-soap将有效负载解组到soapJaxb开箱即用
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
>
<xs:element name="Customer">
<xs:complexType >
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="Address" type="xs:string"/>
<xs:element name="ListOfOrders" type="order" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="order">
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="ProductName" type="xs:string"/>
<xs:element name="ListOfDevice" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="DeviceName" type="xs:string"/>
<xs:element name="ManufactureDate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.example.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:custDetails>
<ser:Customer>
<Id>1-abc</Id>
<Address>23 Sydney Oxley road</Address>
<ListOfOrders>
<Id>P1344</Id>
<ProductName>DRAM</ProductName>
<ListOfDevice>
<DeviceName>20nm</DeviceName>
<ManufactureDate>15-8-2017</ManufactureDate>
</ListOfDevice>
</ListOfOrders>
</ser:Customer>
</ser:custDetails>
</soapenv:Body>
</soapenv:Envelope>
1-abc
悉尼奥克斯利路23号
P1344
德拉姆
20纳米
15-8-2017
根据更新的问题进行编辑 您尝试根据问题顶部发布的XML模式,使用Jax-B解组请求负载
但是在这个模式中,元素
custDetails
不存在。它存在于WSDL的模式部分,但不存在于模式中?!?因此,错误意外元素
非常感谢您的回复。我认为生成的wsdl是正确的。如果观察上面的第2点,我们得到了@webmethod custDetails,结果是wsdl部分。我开始认为使用soapUI进行测试是不可行的。soapUI对于测试web服务来说非常流行,这应该可以很好地工作。有关更多详细信息,您需要将WSDL添加到您的问题中。否则就不可能看到请求的样子。wsdl:operation
元素引用了一条消息tns:custDetails
,而wsdl:message
元素定义了该消息。它尝试了这些操作,但不起作用。我很好奇为什么它失败了。当我没有用骆驼路线包裹它时,一切都很完美。此外,如果将CxfEndpoint设置为POJO模式,它将工作并将消息正文正确绑定到customer类13分钟前,我还不知道CodeFirstWeb服务是否很好,但显然问题出在请求包装器元素上。不确定@RequestWrapper
注释在这种情况下是否有帮助。但是,在有效负载模式下,您只需将soap:Body
内容作为XML(包括custDetails
元素)获取,并且当custDetails
元素不是已知类型的一部分时,您无法使用Jax-B将其解组。您必须“解包”首先是Customer元素。在POJO模式下,CXF还处理主体,它从WSDL中知道custDetails
元素。
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.example.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:custDetails>
<ser:Customer>
<Id>1-abc</Id>
<Address>23 Sydney Oxley road</Address>
<ListOfOrders>
<Id>P1344</Id>
<ProductName>DRAM</ProductName>
<ListOfDevice>
<DeviceName>20nm</DeviceName>
<ManufactureDate>15-8-2017</ManufactureDate>
</ListOfDevice>
</ListOfOrders>
</ser:Customer>
</ser:custDetails>
</soapenv:Body>
</soapenv:Envelope>