PHP并没有Soap动作标题

kin*_*005 5 php wsdl web-services

我正试图在我的公司内拨打远程网络服务.出于专有原因,我无法提供Web服务的URL.Web服务有一个名为getItemField的函数.这是一个小型测试服务,我正在尝试运行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>
Run Code Online (Sandbox Code Playgroud)

我可以很好地连接到服务并打印出单个函数和类型的名称,但是当我尝试调用函数时,我得到'没有SOAPAction头!' 错误.我调用服务函数的PHP代码如下:

$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 );
Run Code Online (Sandbox Code Playgroud)

根据服务的描述,它似乎没有定义soapaction.我用soapAction看到的那条线是<wsdlsoap:operation soapAction=""/>.我试图指定一个空白的soapAction,因为没有定义,但这似乎不起作用.Web服务定义本身是否不完整?或者我在客户端应用程序调用中缺少一些参数?提前致谢.

更新:

试图将方法名称指定为soap操作,但htat不起作用.

    //Params
    $params = array( '123456' );

    //Options
    $options = array( 'soapaction' => 'getItemField' );

    //Call function (STILL THROWS 'no SOAPAction header!')
    $result = $client->__soapCall( "getItemField", $params, $options );
Run Code Online (Sandbox Code Playgroud)

如果在wsdl中没有指定soapAction,我该怎么办,即如果它设置为"".

pro*_*ime -1

如果没有所有必要的详细信息,很难提供帮助,但我建议您尝试以下操作:

//Replace accordingly: see PHP Manual
//(http://www.php.net/manual/en/soapheader.soapheader.php)

$header = new SoapHeader($namespace, $name, $data, $mustunderstand, $actor);
$client->__setSoapHeaders($header);

//Main soap call follows....
Run Code Online (Sandbox Code Playgroud)

在致电肥皂服务之前。希望这可以帮助。