[請益] SOAP使用WebService發生問題

看板PHP作者 (...)時間17年前 (2008/08/08 12:38), 編輯推噓1(103)
留言4則, 1人參與, 最新討論串1/1
各位好,因為我對於Soap還沒有很熟悉 所以有些問題如果太笨了~~請見諒 以下是對方WebService的要求: POST /Passport/SingleSignOn.asmx HTTP/1.1 Host: passport.gigabyte.com.tw Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.gigabyte.passport/WebService/logonUser" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <logonUser xmlns="" rel="nofollow">http://www.gigabyte.passport/WebService"> <email>string</email> <pwd>string</pwd> <userIP>string</userIP> <Path>string</Path> </logonUser> </soap:Body> </soap:Envelope> 以下是我用php寫的soap: <?php $client = new SoapClient(null, array('location' => "https://passport.gigabyte.com.tw/Passport/SingleSignOn.asmx?op=logonUser",'uri' => "http://www.gigabyte.passport/WebService/logonUser")); $str = "<soap:Envelope xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\”http://www.w3.org/2001/XMLSchema\” xmlns:soap=\""" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/\">" + "<soap:Body>" + "<logonUser xmlns=\""" rel="nofollow">http://www.gigabyte.passport/WebService\">" + "<email>" + test + "</email>" + "<pwd>" + test + "</pwd>" + "<userIP>" + test + "</userIP>" + "<Path>" + test + "</Path>" + "</logonUser>" + "</soap:Body>" + "</soap:Envelope>"; try{ $reversed = $client->reverse($str); }catch(SoapFault $fault){ echo "Fault! code:",$fault->faultcode,", string: ",$fault->faultstring; } ?> 執行之後錯誤訊息是 Fault! code:soap:Client, string: 伺服器無法辨認 HTTP 標頭 SOAPAction 的值: http://www.gigabyte.passport/WebService/logonUser#reverse。 header加入的方法我不是很懂,是看php官網的範例改的 $client->__soapCall("echoVoid", null, null, new SoapHeader('http://www.gigabyte.passport/WebService/logonUser', 'echoMeStringRequest', 'hello world')); 加在$client的下面,不過加入之後的這行有錯 錯誤訊息是 SoapClient::__soapCall() expects parameter 2 to be array, null given in C:\wamp\www\soap\gigaapi.php on line 8 請各位前輩指點我一下 非常感謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.223.216

08/09 03:07, , 1F
expects parameter 2 to be array
08/09 03:07, 1F

08/09 03:08, , 2F
代表第二個參數要給它array 不能是null
08/09 03:08, 2F

08/09 03:09, , 3F

08/09 03:09, , 4F
有_soapCall範例
08/09 03:09, 4F
文章代碼(AID): #18cysmls (PHP)
文章代碼(AID): #18cysmls (PHP)