当部件访问器元素使用名称空间限定时,JavaJAX WS-webservice接收空参数
我已经使用NetBeans7.0和JAX-WS实现了一个web服务
当soapui调用web服务时,它会正常工作。当SAP CRM调用它时,web服务实现会收到null参数:在下面的示例中,userId是null而不是“foo”。(userId的类型为String)
SOAP UI发送的SOAP消息是:
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:IciSystemInterface">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<urn:getWorkcenterCapability>
<userId>foo</userId>
</urn:getWorkcenterCapability>
</soapenv:Body>
</soapenv:Envelope>
SAP CRM发送的SOAP消息为:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<pre:user xmlns:pre="urn:IciSystemInterface" SOAP-ENV:mustUnderstand="0" xsi:type="xsd:string">IC_AGENT_SRV</pre:user>
<pre:language xmlns:pre="urn:IciSystemInterface" SOAP-ENV:mustUnderstand="0" xsi:type="xsd:string">EN</pre:language>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns0:getWorkcenterCapability xmlns:ns0="urn:IciSystemInterface">
<userId xmlns="urn:IciSystemInterface">foo</userId>
</ns0:getWorkcenterCapability>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
如果我从userId标记中删除xmlns属性,它就会工作(我进行了更改,并通过使用HTTP客户端调用web服务对其进行了测试):
<ns0:getWorkcenterCapability xmlns:ns0="urn:IciSystemInterface">
<userId>foo</userId>
</ns0:getWorkcenterCapability>
问题是我无法改变SAP CRM的呼叫方式。有没有办法让JAX-WS忽略部分访问器元素的名称空间
先谢谢你
# 1 楼答案
我听从了@Branden的建议。我使用SoapHandler捕获对web服务的调用,并在JAX-WS调用我的web服务实现之前处理soap消息。成功了