我已经通过wsimport从远程wsdl生成了存根文件,并创建了一个独立的客户端。现在,当我运行客户端时,生成的HTTP请求是:
HTTP标头:
---[HTTP request - http://www.transportdirect.info/EnhancedExposedServices/CarJourneyPlannerSynchronous/v1/CarJourneyPlannerSynchronousService.asmx]---
Content-type: text/xml;charset="utf-8"
Soapaction: "http://www.transportdirect.info/TransportDirect.EnhancedExposedServices.CarJourneyPlannerSynchronous.V1/GetGridReference"
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
HTTP正文:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</S:Header>
<S:Body>
<GetGridReference xmlns="http://www.transportdirect.info/TransportDirect.EnhancedExposedServices.CarJourneyPlannerSynchronous.V1">
<transactionId>bfe2ccbe-9197-4992-9073-cd3a3c0e5c47</transactionId>
<locationType>Postcode</locationType>
<locationValue>W11</locationValue>
</GetGridReference>
</S:Body>
</S:Envelope>
现在,SOAP Envelope部分完全没问题,因为我已经使用SOAP工具测试它并且输出正确。但上面的HTTP请求总是给我
---[HTTP response - http://www.transportdirect.info/EnhancedExposedServices/CarJourneyPlannerSynchronous/v1/CarJourneyPl
annerSynchronousService.asmx - 500]---
null: HTTP/1.1 500 Internal Server Error
Cache-control: private
X-ua-compatible: IE=EmulateIE7
Content-type: text/html; charset=utf-8
Content-length: 7424
Connection: close
X-powered-by: ASP.NET
后面跟着很多html标签,描述了一些错误。
我的Java客户端代码如下所示 -
CarJourneyPlannerSynchronousService service = new CarJourneyPlannerSynchronousService();
port = service.getCarJourneyPlannerSynchronousServiceSoap();
port.getGridReference(transactionId, "bla-bla", "bla-bla");
你能告诉我在这里缺少什么吗?如果您想查看更多代码,请与我们联系。
答案 0 :(得分:0)
注意线:
HTTP/1.1 500 Internal Server Error
它表明服务器端出现了问题。检查服务器日志,您将找到错误原因。
如果您无法访问服务器,请查看Web服务的文档,并检查是否发送了一些可能导致服务器崩溃的不当参数(由于您提到您测试了SOAP请求,因此非常不可能)其他工具)。我怀疑你的HTTP标头中的soapaction
字段,因为基于.NET的Web服务经常遇到问题 - 如果你发送一个他们不期望的值,你可能会得到错误500.
参考文献: