2012-04-19 129 views
1

我正在嘗試在英國使用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> 
+1

你能提供一個鏈接到WSDL嗎? – Michael 2012-04-19 20:26:32

+0

我強烈懷疑這是因爲生成的客戶端類文件。我會建議重新生成它們並嘗試。 – kosa 2012-04-19 20:27:59

+0

對不起,指向WSDL的鏈接是:https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL – 2012-04-19 20:46:46

回答

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額外的命名空間的進口,以簡化和整潔的要求。
相關問題