简体   繁体   English

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

[英]Not able to get response from a third party web service

I am trying to use QAS web services for postcode lookup in UK. 我正在尝试使用QAS网络服务在英国进行邮政编码查询。 When I am posting my request XML, it says "Server did not recognize the value of HTTP Header SOAPAction: DoSearch." 当我发布我的请求XML时,它说“服务器无法识别HTTP标头SOAPAction的价值:DoSearch”。

When I remove mMethod.setRequestHeader("SOAPAction", "/DoSearch"); 当我删除mMethod.setRequestHeader(“SOAPAction”,“/ DoSearch”)时; from my SOAPClient, the error then received is Unable to handle request without a valid action parameter. 从我的SOAPClient,然后收到的错误是无法处理请求没有有效的操作参数。 Please supply a valid soap action. 请提供有效的肥皂行动。

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

I guess promlem is that I am not being able to set the action parameter in the header, but I dont have any clue on how to do so, and I am kind of stuck. 我想promlem是我无法在标题中设置action参数,但我没有任何关于如何这样做的线索,我有点卡住了。 Please help. 请帮忙。

The request XML which I am trying to post is: 我想发布的请求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>

Sorry this is so late, I've only just seen your question - I certainly hope you have been able to sort this out before now! 对不起,这太晚了,我刚刚看到你的问题 - 我当然希望你能够在此之前解决这个问题!

Did you use an automated tool to create that request from the WSDL or create it manually? 您是否使用自动化工具从WSDL创建该请求或手动创建它? There are a few problems with the structure of your request that if we change should allow requests. 您的请求结构存在一些问题,如果我们更改应该允许请求。

To get it working you need to be using a structure similar to: 要使其正常工作,您需要使用类似于以下的结构:

<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>

There are few things I've changed. 我改变的事情很少。

  • qas:QAQueryHeader has been added to your header. qas:QAQueryHeader已添加到您的标题中。 This is required by the QAS OnDemand service. 这是QAS OnDemand服务所必需的。
  • Corrected your namespace (underscore to dash): 更正了您的命名空间(下划线到破折号):
    • Before: xmlns:qas="http://www.qas.com/OnDemand _ 2011-03" 之前:xmlns:qas =“http://www.qas.com/OnDemand _ 2011-03”
    • After:xmlns:qas="http://www.qas.com/OnDemand - 2011-03" 之后:xmlns:qas =“http://www.qas.com/OnDemand - 2011-03”
  • Removed the extra namespace import for QASearch to simplify and tidy the request. 删除了QASearch的额外命名空间导入,以简化和整理请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM