一个或多个http请求标头对SOAP请求无效

时间:2014-06-11 17:33:39

标签: java web-services soap

我正在尝试将我的Java应用程序与Channel Advisor API连接,我收到此错误:

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>Server was unable to process request. One or more http request headers was not valid for the SOAP request. </faultstring>
            <detail/>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

这是我的要求:

String requestURL = "https://api.channeladvisor.com/ChannelAdvisorAPI/v7/InventoryService.asmx";
String request = 
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'   xmlns:web='http://api.channeladvisor.com/webservices/'>"+
   "<soapenv:Header>"+
      "<web:APICredentials>"+
         "<!--Optional:-->"+
         "<web:DeveloperKey>XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX</web:DeveloperKey>"+
         "<!--Optional:-->"+
         "<web:Password>XXXXXXXXXX</web:Password>"+
      "</web:APICredentials>"+
   "</soapenv:Header>"+
   "<soapenv:Body>"+
      "<web:GetInventoryQuantity>"+
         "<web:accountID>XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXX</web:accountID>"+
         "<web:sku>XXXXXX-XX-XXX</web:sku>"+
      "</web:GetInventoryQuantity>"+
   "</soapenv:Body>"+
"</soapenv:Envelope>";

奇怪的是,如果我用SoapUI尝试相同的请求,我会得到一个成功的回复。

知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

您是否尝试过处理Web服务返回的实际消息(强调我的)?

  

服务器无法处理请求。一个或多个 http请求标头对SOAP请求无效

如果它可以从SoapUI运行,那么这意味着您没有从Java应用程序发送正确的请求。 SoapUI在执行请求时会记录一些logs。您可以查看HTTP日志并查看它发送的标头。

我猜你错过了SOAPActionContent-Type。开始逐个添加标题,看看Web服务何时停止抱怨。