我想在我的公司內調用遠程Web服務。出於專有原因,我無法提供網絡服務的URL。該Web服務具有一個稱爲getItemField的單個函數。這是我想針對其運行PHP一個小的測試服務,該服務的描述如下:PHP和沒有肥皂動作標題
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://www.oracle.com/ws/MyFirstWebService" xmlns:intf="http://www.oracle.com/ws/MyFirstWebService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://www.w3.org/1999/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.oracle.com/ws/MyFirstWebService">
<!--
WSDL created by Apache Axis version: 1.2alpha Built on Oct 23, 2007 (12:09:54 IST)
-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.oracle.com/ws/MyFirstWebService">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_xsd_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
<message name="getItemFieldRequest">
<part name="args" type="impl:ArrayOf_xsd_string"/>
</message>
<message name="getItemFieldResponse">
<part name="getItemFieldReturn" type="soapenc:string"/>
</message>
<portType name="MyFirstWebService">
<operation name="getItemField" parameterOrder="args">
<input message="impl:getItemFieldRequest" name="getItemFieldRequest"/>
<output message="impl:getItemFieldResponse" name="getItemFieldResponse"/>
</operation>
</portType>
<binding name="MyFirstWebServiceSoapBinding" type="impl:MyFirstWebService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getItemField">
<wsdlsoap:operation soapAction=""/>
<input name="getItemFieldRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://first" use="encoded"/>
</input>
<output name="getItemFieldResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.oracle.com/ws/MyFirstWebService" use="encoded"/>
</output>
</operation>
</binding>
<service name="MyFirstWebServiceService">
<port binding="impl:MyFirstWebServiceSoapBinding" name="MyFirstWebService">
<wsdlsoap:address location="http://myWebsite.com/services/MyFirstWebService"/>
</port>
</service>
</definitions>
我可以連接到服務就好了,並打印出單功能和類型的名稱,但是當我嘗試調用一個函數時,我得到'no SOAPAction header!'錯誤。我的PHP代碼來調用服務功能如下:基於有一個定義的SOAPAction它不會出現在服務的描述
$options = array(
// Dev
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
// Credentials
'login' => 'user',
'password' => 'pass'
);
// Connected successfully
$client = new SoapClient("http://myWebsite.com/services/MyFirstWebService?wsdl", $options);
//Params
$params = array('123456');
//Options
$options = array('soapaction' => '""');
//Call function (Both methods below throw the same 'no SOAPAction header!' error)
//$result = $client->getItemField(new SoapParam($params, "getItemFieldRequest"));
$result = $client->__soapCall("getItemField", array('123456'), $options);
。我用soapAction看到的這條線是<wsdlsoap:operation soapAction=""/>
。我試圖指定一個空白的soapAction,因爲沒有定義,但似乎沒有工作。 Web服務定義本身是否不完整?或者我在客戶端應用程序調用中缺少一些參數?提前致謝。
UPDATE:
試圖以指定的方法名作爲SOAP動作,但htat沒有工作。
//Params
$params = array('123456');
//Options
$options = array('soapaction' => 'getItemField');
//Call function (STILL THROWS 'no SOAPAction header!')
$result = $client->__soapCall("getItemField", $params, $options);
那我如果WSDL,即沒有指定的soapAction做,如果它被設置爲「」。
對此有何更新?當我嘗試通過curl連接到可以通過Zend soap連接的web服務時,我遇到了同樣的問題,所以我想它與一些選項或標頭相關。 –
不是與HTTP標頭相關的SOAPAction標頭嗎?檢查http://www.oreillynet.com/xml/blog/2002/11/unraveling_the_mystery_of_soap.html – pedromanoel