Apache Camel CXF Неожиданный элемент - PullRequest
0 голосов
/ 03 марта 2019

У меня есть проект Apache Camel, который использует CXF для отправки полезной нагрузки SOAP.Проект работает безупречно более года.

Недавно мне дали новый WSDL для реализации для этой службы ... Ничто в WSDL не предполагает изменения полезной нагрузки Iотправляю ( те же классы и объекты-значения и т. д. ) ... предполагается, что изменения в WSDL полностью не связаны с полезной нагрузкой, которую я отправляю.

Я использовал wsdl2java, вмой Maven POM, чтобы генерировать исходные тексты Java из WSDL (, как я делал до ), и все компиляции просто отлично, а сервис разворачивается нормально ( JBoss Fuse ).

Однако когда я отправляю полезную нагрузку, служба жалуется, что существует « неожиданный элемент » ... это странно, поскольку я не изменил полезную нагрузку и мыло «Имя операции»Я звоню так же, как со старым WSDL ... новый WSDL имеет другое имя "serviceClass", однако метод, который мне нужно вызвать, тот же.

В выводе журнала я вижу soapAction is nне установлен но я не уверен, что это должно иметь значение ... еще раз, код работал нормально с предыдущим WSDL, который по существу имеет те же элементы serviceClass.

Как можно видеть вфрагмент кода, я пытаюсь использовать операцию createEDIInvoices из WSDL ... эта операция ожидает объект createEDIInvoices (, который я определенно передаю ) ... хотя журнал показывает, чтоSOAP-сервер ожидал createEDIInvoicesResponse:

Неожиданный элемент {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices найден.
Ожидаемый {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoicesResponse.

В любом случае, мнения по этому вопросу приветствуются ... IМне интересно, если я не делаю достаточно, чтобы указать правильную операцию SOAP для выполнения

Вот соответствующий фрагмент кода из моего маршрута Camel ... обратите внимание, что код дует на to ("cxf :... ") call ... bean-компонент никогда не вызывается

 from("direct:inspyrus-processing")

            // specify SOAP operation as defined in WSDL
            .setHeader(CxfConstants.OPERATION_NAME,
                        constant("createEDIInvoices"))
            .setHeader(Inspyrus_Auth_Header, simple("{{inspyrus.auth.header}}"))
            .to("cxf:http://fergusonsbx.invoice-automation.com/ExternalInspyrusService/ExternalInspyrusService" + 
                "?serviceClass=com.inspyrus.generated.invoiceprocessingservice.ExternalInspyrusService" + 
                "&wsdlURL=wsdl/Inspyrus_030119.wsdl" + "&cxfEndpointConfigurer=#cxfConfigurer" + "&loggingFeatureEnabled=true")
            .to("bean:parse-inspyrusresponse")
            .removeHeader(Inspyrus_Auth_Header)
            .log(LoggingLevel.DEBUG, Constants.APP_ID + ": Inspyrus Processing Complete");

Код CXFConfigurer приведен ниже:

ManagedBean
@Named("cxfConfigurer")
public class CxfConfigurer implements CxfEndpointConfigurer {
    private static final long CXF_CONNECTION_TIMEOUT = 180000;
    private static final long CXF_RECEIVE_TIMEOUT = 360000;

    @Override
    public void configure(final AbstractWSDLBasedEndpointFactory factoryBean) {

    }

    @Override
    public void configureClient(final Client client) {
        final HTTPConduit http = (HTTPConduit) client.getConduit();
        final HTTPClientPolicy policy = http.getClient();
        policy.setAutoRedirect(true);
        policy.setConnection(ConnectionType.KEEP_ALIVE);
        policy.setConnectionTimeout(CXF_CONNECTION_TIMEOUT);    // default is 30K
        policy.setReceiveTimeout(CXF_RECEIVE_TIMEOUT);          // default is 60K
        // Don't be too strict with CN checking
        final TLSClientParameters tlsCP = new TLSClientParameters();
        tlsCP.setDisableCNCheck(true);
        http.setTlsClientParameters(tlsCP);

    }

    @Override
    public void configureServer(final Server server) {

    }

WSDL был сгенерирован из http://fergusonsbx.invoice -автоматики.com / ExternalInspyrusService / ExternalInspyrusService? wsdl ... ниже

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. --><definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://xmlns.inspyrus.com/ExternalInspyrusService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://xmlns.inspyrus.com/ExternalInspyrusService" name="ExternalInspyrusService">
<types>
<xsd:schema>
<xsd:import namespace="http://xmlns.inspyrus.com/ExternalInspyrusService" schemaLocation="ExternalInspyrusService_1.xsd"/>
</xsd:schema>
</types>
<message name="createEDIInvoices">
<part name="parameters" element="tns:createEDIInvoices"/>
</message>
<message name="createEDIInvoicesResponse">
<part name="parameters" element="tns:createEDIInvoicesResponse"/>
</message>
<portType name="ExternalInspyrusService">
<operation name="createEDIInvoices">
<input message="tns:createEDIInvoices"/>
<output message="tns:createEDIInvoicesResponse"/>
</operation>
</portType>
<binding name="ExternalInspyrusServicePortBinding" type="tns:ExternalInspyrusService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="createEDIInvoices">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ExternalInspyrusService">
<port name="ExternalInspyrusServicePort" binding="tns:ExternalInspyrusServicePortBinding">
<soap:address location="http://fergusonsbx.invoice-automation.com:80/ExternalInspyrusService/ExternalInspyrusService"/>
</port>
</service>
</definitions>

Соответствующие фрагменты журнала

ID: 1
Address: http://fergusonsbx.invoice-automation.com/ExternalInspyrusService/ExternalInspyrusService
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], accountId=[SANAN], Authorization=[n5zMltp5l2z2L+2tDC9l], breadcrumbId=[ID-fuse-localdomain-43307-1551479341458-13-1], Connection=[Keep-Alive], DESTINATION_SELL_LOCATION=[454], EDI_810_PONUMBER=[L454-11593], ISFREIGHT=[false], MAIN_BRANCH_NUMBER=[0061], PO_TYPE=[DIRECT], PROCESSED=[true], **SOAPAction=[""]**, SOURCE_PARTY_ID=[22449], UNPROCESSED_VENDORID=[SANAN*10770~1~1], UNPROCESSED_VENDORNUMBER=[10770], WAREHOUSE_NUMBER=[454]}


**Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:createEDIInvoices xmlns:ns2="http://xmlns.inspyrus.com/ExternalInspyrusService"><entityID>23 ....

16:47:18,662 INFO  [org.apache.cxf.services.ExternalInspyrusService.ExternalInspyrusServicePort.ExternalInspyrusService] (default-workqueue-1) Inbound Message**
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Date=[Sat, 02 Mar 2019 16:51:54 GMT], transfer-encoding=[chunked]}
Payload: <?xml version='1.0' encoding='UTF-8'?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header/><soap:Body><ns2:createEDIInvoices xmlns:ns2="http://xmlns.inspyrus.com/ExternalInspyrusService"><entityID>23</entityID><invoiceImport><header><captureProfile>EDI</captureProfile><currencyCode>USD</currencyCode><documentType>Invoice</documentType><flexAttribute10>Batch # 543421</flexAttribute10><flexAttribute12>543421</flexAttribute12><flexAttribute17>347.46</flexAttribute17><flexAttribute19>ST005.txt</flexAttribute19><flexAttribute21>120.46</flexAttribute21><flexAttribute22>16B286664984</flexAttribute22><flexAttribute23>EXLA ESTES EXPRESS LINES</flexAttribute23><flexAttribute24>W196-12965 </flexAttribute24><flexAttribute26>1% DISC 30 Days</flexAttribute26><flexAttribute27>2.22</flexAttribute27><flexAttribute28>February 17, 2019</flexAttribute28><flexAttribute29>February 16, 2019</flexAttribute29><flexAttribute3>125.00</flexAttribute3><flexAttribute30>1.00%</flexAttribute30><flexAttribute5>0454</flexAttribute5><flexAttribute6>DIRECT</flexAttribute6><flexAttribute8>SANAN*22449*383148735</flexAttribute8><invoiceDate>2019-01-17</invoiceDate><invoiceNumber>383148735</invoiceNumber><invoiceStatus>Open</invoiceStatus><invoiceTotalAmount>347.46</invoiceTotalAmount><leAddress1>PO BOX 9406</leAddress1><leCity>HAMPTON</leCity><leName>FERGUSON - HAMPTON</leName><lePostalCode>23670</lePostalCode><leState>VA</leState><orgID>0061</orgID><PONumber>L454-11593</PONumber><region>NA</region><scanDate>2019-01-17</scanDate><shipToAddress1>5206 W WATERS AVENUE</shipToAddress1><shipToCity>TAMPA</shipToCity><shipToName>FERGUSON 0196 TAMPA</shipToName><shipToPostalCode>33634</shipToPostalCode><shipToState>FL</shipToState><vendorAddress1>P.O Box 202893</vendorAddress1><vendorCity>DALLAS</vendorCity><vendorID>SANAN*22449~1~1</vendorID><vendorName>AS America, Inc.</vendorName><vendorNumber>22449</vendorNumber><vendorPostalCode>75320</vendorPostalCode><vendorSiteID>SANAN*22449~1~1</vendorSiteID><vendorState>TX</vendorState></header><lineItems><lineItem><lineNumber>1</lineNumber><lineType>ITEM</lineType><description>@ 5 FT AFR BATH LH OUT SOLAR WH</description><quantity>1</quantity><unitPrice>227.0000</unitPrice><lineTotalAmount>227.00</lineTotalAmount><UOM>EA</UOM><attribute4>0263212.020</attribute4><attribute5>A0263212020</attribute5></lineItem><lineItem><lineNumber>2</lineNumber><lineType>ITEM</lineType><description>Warranty</description><quantity>1</quantity><unitPrice>-4.5400</unitPrice><lineTotalAmount>-4.54</lineTotalAmount></lineItem></lineItems></invoiceImport></ns2:createEDIInvoices><soap:Fault><faultcode>F</faultcode><faultstring>Authorization Token not Found</faultstring></soap:Fault></soap:Body></soap:Envelope>
--------------------------------------
16:47:18,663 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default-workqueue-1) Interceptor for {http://xmlns.inspyrus.com/ExternalInspyrusService}ExternalInspyrusService#{http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices has thrown exception, 
unwinding now: org.apache.cxf.interceptor.Fault: 
Unexpected element {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices found.   
Expected {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoicesResponse.
...