1

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

当我删除 mMethod.setRequestHeader("SOAPAction", "/DoSearch"); 从我的 SOAPClient 收到的错误是无法在没有有效操作参数的情况下处理请求。请提供有效的肥皂动作。

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

我想问题是我无法在标题中设置动作参数,但我不知道如何设置,而且我有点卡住了。请帮忙。

我要发布的请求 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>
4

1 回答 1

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 的额外命名空间导入,以简化和整理请求。
于 2014-02-14T14:58:25.770 回答