无法从第三方Web服务获得响应
问题描述:
我正在尝试在英国使用QAS Web服务进行邮政编码查找。当我发布我的请求XML时,它说“服务器无法识别HTTP Header SOAPAction:DoSearch的值。”无法从第三方Web服务获得响应
当我删除mMethod.setRequestHeader(“SOAPAction”,“/ DoSearch”);从我的SOAPClient收到的错误是 如果没有有效的操作参数,则无法处理请求。请提供有效的肥皂行动。
到WSDL的链接是: https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL
我猜promlem的是,我不能够设置在标题中的作用参数,但我没有对如何做到这一点的任何线索,我那种卡住了。请帮忙。
而我试图张贴请求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>
答
对不起,这是这么晚了,我只是刚刚看到你的问题 - 我当然希望你已经能够解决这之前,现在!
您是否使用自动化工具从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额外的命名空间的进口,以简化和整洁的要求。
你能提供一个链接到WSDL吗? – Michael 2012-04-19 20:26:32
我强烈怀疑这是因为生成的客户端类文件。我会建议重新生成它们并尝试。 – kosa 2012-04-19 20:27:59
对不起,指向WSDL的链接是:https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL – 2012-04-19 20:46:46