我有一个使用CXF发送SOAP有效负载的Apache Camel项目。该项目已经完美地工作了一年以上。
最近,为我提供了一个新的WSDL来实现此服务... WSDL中的任何内容都不应该更改有效负载 我正在发送(相同的类和值对象等)。。。WSDL中的更改被认为与 我正在发送的有效载荷。
我在Maven POM中使用wsdl2java从WSDL生成Java源代码(如我以前所做的 ),所有编译都很好,服务部署也很好( JBoss Fuse )。
但是,当我发送有效载荷时,服务抱怨有一个“ 意外元素 ” ...这是 奇怪,因为我没有更改有效负载,并且我正在调用的Soap“操作名称”与旧的相同 WSDL ...新的WSDL具有不同的“ serviceClass”名称,但是,我需要调用的方法是相同的。
在日志输出中,我看到 soapAction 是 未设置 ,但是我不确定这应该很重要...再次,的 以前的WSDL本质上具有相同的serviceClass元素,因此代码运行良好。
从代码片段中可以看出,我正在尝试使用WSDL中的 createEDIInvoices 操作... 该操作需要一个createEDIInvoices对象(我一定要传递的 )...尽管日志显示 SOAP服务器期望的是createEDIInvoicesResponse:
找到了意外的元素{http://xmlns.inspyrus.com/ExternalInspyrusService} createEDIInvoices。
预期{http://xmlns.inspyrus.com/ExternalInspyrusService}创建EDIInvoicesResponse。
无论如何,欢迎对此问题发表意见...我有点想知道我是否没有做足够的工作来指定要执行的正确SOAP操作
这是我骆驼路线中的相关代码片段...请注意,该代码在to(“ cxf:...”)调用上吹响了……从没调用过该豆
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-automation.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.