无法从第三方Web服务获得响应

时间:2012-04-19 20:24:51

标签: java web-services soap wsdl http-headers

我正在尝试使用QAS网络服务在英国进行邮政编码查询。当我发布请求XML时,它说“服务器无法识别HTTP标头SOAPAction的值:DoSearch。”

当我删除mMethod.setRequestHeader(“SOAPAction”,“/ DoSearch”)时;从我的SOAPClient,然后收到的错误是 没有有效的操作参数,无法处理请求。请提供有效的肥皂活动。

WSDL的链接是: https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL

我想promlem是我无法在标题中设置action参数,但是我没有任何关于如何这样做的线索,而且我有点卡住了。请帮忙。

我想发布的请求XML是:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:qas="http://www.qas.com/OnDemand_2011-03">
<soap:Header>
<qas:QAAuthentication>
<qas:Username>username</qas:Username>
<qas:Password>password</qas:Password>
</qas:QAAuthentication>
</soap:Header>
<soap:Body>
<QASearch RequestTag="Single Line postcode search"
xmlns:web="http://www.qas.com/OnDemand_2011_03">
<web:Country>GBR</web:Country>
<web:Engine Flatten="true ">Singleline</web:Engine>
<web:Layout>QADefault</web:Layout>
<web:Search>B168JR</web:Search>
</QASearch>
</soap:Body>
</soap:Envelope>

1 个答案:

答案 0 :(得分:3)

对不起,这太晚了,我刚刚看到你的问题 - 我当然希望你能够在此之前解决这个问题!

您是否使用自动化工具从WSDL创建请求或手动创建?您的请求结构存在一些问题,如果我们更改应该允许请求。

要使其正常工作,您需要使用类似于以下的结构:

<soap:Envelope
       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:qas="http://www.qas.com/OnDemand-2011-03">
<soap:Header>
<qas:QAQueryHeader>
    <qas:QAAuthentication>
        <qas:Username>username</qas:Username>
        <qas:Password>password</qas:Password>
    </qas:QAAuthentication>
</qas:QAQueryHeader>
</soap:Header>
<soap:Body>
    <qas:QASearch>
        <qas:Country>GBR</qas:Country>
        <qas:Engine Flatten="true ">Singleline</qas:Engine>
        <qas:Layout>QADefault</qas:Layout>
        <qas:Search>B168JR</qas:Search>
    </qas:QASearch>
</soap:Body>
</soap:Envelope>

我改变了一些事情。

  • qas:QAQueryHeader已添加到您的标头中。这是QAS OnDemand服务所必需的。
  • 更正了您的命名空间(下划线到破折号):
    • 之前:xmlns:qas =“http://www.qas.com/OnDemand_2011-03”
    • 后:的xmlns:QAS = “http://www.qas.com/OnDemand-2011-03”
  • 删除了QASearch的额外命名空间导入,以简化和整理请求。