問題描述
我是 SOAP 新手,正在處理一項 Web 服務(wù),以前似乎沒有人使用 PHP 進(jìn)行連接.除了 C#,他們沒有示例代碼,但我有.eServices.asmx 提供了 WSDL,如果這是正確的說法的話.
I am new to SOAP and dealing with a web service where it would seem no one has interfaced using PHP previously. They have no example code excepting C# but I do have that. eServices.asmx provides WSDL if that is the correct way to say that.
我得到的錯誤是服務(wù)器無法識別 HTTP Header SOAPAction 的值:",其中訓(xùn)練冒號表明可能沒有傳遞任何值.
The error that I am getting is "Server did not recognize the value of HTTP Header SOAPAction:" with that training colon suggesting no value is passed, maybe.
我的代碼如下:
$URL = "http://nolaflash.example.com/xxxWS/eServices.asmx";
$namespace="http://www.example.com/webservices/";
include("SOAP/Client.php");
$soapclient = new SOAP_Client($URL);
$xml_data = // valid XML is here;
$res = $soapclient->UpdateData('usrname','pass',$xml_data);
但我也嘗試過:
$param = array('usrname','pass',$xml_data);
$res = $soapclient->call('UpdateData',$param, $namespace);
谷歌搜索表明此錯誤是命名空間問題.我的 C# 代碼只有一個命名空間引用:
Googling suggests that this error is a namespace issue. The C# code I have has only one namespace reference:
[System.Web.Services.WebServiceBindingAttribute(Name="eServicesSoap", Namespace="http://www.example.com/webservices/")]
如果我在函數(shù)調(diào)用之前將 $soapclient 轉(zhuǎn)儲到屏幕上,我會看到它已從 eServices.asmx 接收到數(shù)據(jù).
If I dump $soapclient to the screen prior to the function call I see that it has received data from eServices.asmx.
我不確定如何進(jìn)行調(diào)試,而且該服務(wù)的工作人員不熟悉在其 .NET IDE 之外與該服務(wù)進(jìn)行交互.
I am unsure how to go about debugging this and the staffers at the service are unfamiliar with interacting with the service outside their .NET IDE.
有什么想法嗎?建議?
推薦答案
我通常使用的方法是 getFunctions和 getLastRequest幫我解決問題.首先我看一下函數(shù)列表和WSDL.有時 WSDL 和/或服務(wù)器未正確設(shè)置/配置/編碼.所以這個函數(shù)列表可能沒用.WSDL 文件應(yīng)該是明確的,但是唉,編碼器很爛,等等...
I usually use the methods getFunctions and getLastRequest to help me sort things out. First I look at the function list and WSDL. Sometimes the WSDL and/or server is not setup/configured/coded properly. So this function list may be useless. The WSDL file should be definitive, but alas, lame coders, etc...
所以有時我不得不暗中探查,查看錯誤,然后查看最后一個請求.這樣您就可以看到生成的實際 XML.將其與一些有效的 XML 示例進(jìn)行比較.
So sometimes I have to take a stab in the dark, look at the error, and then look at the last request. With this you can see the actual XML that was produced. Compare that to some working XML examples.
事實證明,這在與不想編寫文檔的編碼人員打交道時最有幫助.順便說一下,他們應(yīng)該給出 XML 示例——而不是展示如何使用 XYZ 語言生成 XML.PHP/Soap 文檔
This has proven most helpful when dealing with coders who don't want to write docs. By the way, they should give XML examples - not show how to generate XML using language XYZ. There may be more useful infos in the PHP/Soap documentation
HTH
這篇關(guān)于調(diào)試 PHP SOAP 調(diào)用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!