UnmarshalException: верблюжий мыло неумышленная ошибка неожиданный элемент
[Com.sun.istack.SAXParseException2; номер строки: 1; номер столбца: 1; неожиданный элемент (uri: " http://service.example.com/", local: "custDetails"). Ожидаемые элементы: <{ http://schemas.xmlsoap.org/soap/envelope/} Body>,<{} Customer>,<{ http://schemas.xmlsoap.org/soap/envelope/} Envelope>,< { http://schemas.xmlsoap.org/soap/envelope/} Ошибка>,<{ http://schemas.xmlsoap.org/soap/envelope/} заголовок>]
Постановкапроблемы: Верблюд не ожидает получения custDetails (webmethod) и пространства имен.
Ожидание: использовать верблюжье мыло, чтобы распаковать полезную нагрузку на soapJaxb из коробки.
Сгенерированные классы JAXB с использованием maven-jaxb2-plugin для xsd ниже. Результаты дали три класса с аннотациями - Customer.java, ObjectFactory,java, Order.java.
<?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>
Откройте веб-сервис custDetails(..) следующим образом, используя конечную точку cxf с DataFormat, установленным в PAYLOAD. [ОБНОВЛЕНО с помощью @Configuration]
@Configuration public class WebServiceConfig { @Autowired private Bus bus; @Bean public CxfEndpoint getCustomerDetails() { CxfEndpoint cxfEndpoint = new CxfEndpoint(); cxfEndpoint.setAddress("/customerProvide"); cxfEndpoint.setServiceClass(CustomerSvc.class); cxfEndpoint.setBus(bus); cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);return cxfEndpoint ;} @Webservice public interface CustomerSvc { @WebMethod Customer custDetails ( @WebParam(name="Customer")Customer Customer ) ;} // Simple route in Route class. @Component public class CustomerRoute extends RouteBuilder { public void configure (){ SoapJaxbDataFormat soapDF = new SoapJaxbDataFormat("com.example.service", new TypeNameStrategy()); from("cxf:bean:getCustomerDetails").unmarshal(soapDF) .log("receive : ${body}") }
Wsdl генерируется и импортируется в soapUI. Пример запроса SOAPUI для тестирования выглядит следующим образом.
<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>
Когда я пытаюсь разархивировать PAYLOAD с помощью мыла dataformat, верблюд выдает ошибку. Это ошибка пространства имен. Я не уверен, почему класс package-info не генерируется. Любая помощь с благодарностью. Спасибо.
ОБНОВЛЕНИЕ, wsdl приведено ниже.
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.example.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="CustomerSvcService" targetNamespace="http://service.example.com/"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.example.com/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://service.example.com/"> <xs:element name="Customer"> <xs:complexType> <xs:sequence> <xs:element name="Id" type="xs:string"/> <xs:element name="Address" type="xs:string"/> <xs:element minOccurs="0" name="ListOfOrders" type="tns:order"/> </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 minOccurs="0" name="ListOfDevice"> <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:element name="custDetails" type="tns:custDetails"/> <xs:complexType name="custDetails"> <xs:sequence> <xs:element minOccurs="0" ref="tns:Customer"/> </xs:sequence> </xs:complexType> <xs:element name="custDetailsResponse" type="tns:custDetailsResponse"/> <xs:complexType name="custDetailsResponse"> <xs:sequence> <xs:element minOccurs="0" ref="tns:Customer"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="custDetails"> <wsdl:part element="tns:custDetails" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="custDetailsResponse"> <wsdl:part element="tns:custDetailsResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="CustomerSvc"> <wsdl:operation name="custDetails"> <wsdl:input message="tns:custDetails" name="custDetails"> </wsdl:input> <wsdl:output message="tns:custDetailsResponse" name="custDetailsResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="CustomerSvcServiceSoapBinding" type="tns:CustomerSvc"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="custDetails"> <soap:operation soapAction="" style="document"/> <wsdl:input name="custDetails"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="custDetailsResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="CustomerSvcService"> <wsdl:port binding="tns:CustomerSvcServiceSoapBinding" name="CustomerSvcPort"> <soap:address location="http://localhost:12000/services/customerProvide"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
1 ответ
РЕДАКТИРОВАТЬ из-за обновленного вопроса
Вы пытаетесь разархивировать полезную нагрузку запроса с помощью Jax-B на основе XML-схемы, которую вы разместили в верхней части вашего вопроса.
Но в этой схеме элемент custDetails
не существует Он существует в части схемы вашего WSDL, но не в схеме?!? Поэтому ошибка unexpected element
,