2014-04-09 31 views
0

我需要一些幫助,我有相同名稱PostHours 2個操作的Web服務,但是這有2個動作ForStandardReportForSpecialReport Web服務的WSDL的XML是:PHP __soapCall SOAPACTION

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://company.net/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://company.net/"> 
<wsdl:types/> 
<wsdl:message name="ForStandardReportSoapIn"> 
<wsdl:part name="CallVendorCode" type="s:string"/> 
<wsdl:part name="CallDate" type="s:string"/> 
<wsdl:part name="BTNState" type="s:string"/> 
<wsdl:part name="PromotionCode" type="s:string"/> 
<wsdl:part name="ReportCode" type="s:string"/> 
<wsdl:part name="Hours" type="s:int"/> 
</wsdl:message> 
<wsdl:message name="ForStandardReportSoapOut"> 
<wsdl:part name="ForStandardReportResult" type="s:string"/> 
</wsdl:message> 
<wsdl:message name="ForSpecialReportSoapIn"> 
<wsdl:part name="CallVendorCode" type="s:string"/> 
<wsdl:part name="CallDate" type="s:string"/> 
<wsdl:part name="BTNState" type="s:string"/> 
<wsdl:part name="PromotionCode" type="s:string"/> 
<wsdl:part name="ReportCode" type="s:string"/> 
<wsdl:part name="Hours" type="s:int"/> 
<wsdl:part name="ReportBy" type="s:string"/> 
</wsdl:message> 
<wsdl:message name="ForSpecialReportSoapOut"> 
<wsdl:part name="ForSpecialReportResult" type="s:string"/> 
</wsdl:message> 

<wsdl:portType name="companyReportingWebServiceSoap"> 
    <wsdl:operation name="PostHours"> 
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Post Hours</wsdl:documentation> 
    <wsdl:input name="ForStandardReport" message="tns:ForStandardReportSoapIn"/> 
    <wsdl:output name="ForStandardReport" message="tns:ForStandardReportSoapOut"/> 
    </wsdl:operation> 
    <wsdl:operation name="PostHours"> 
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Post Hours using ReportBy criteria</wsdl:documentation> 
    <wsdl:input name="ForSpecialReport" message="tns:ForSpecialReportSoapIn"/> 
    <wsdl:output name="ForSpecialReport" message="tns:ForSpecialReportSoapOut"/> 
    </wsdl:operation> 
</wsdl:portType> 

<wsdl:binding name="companyReportingWebServiceSoap" type="tns:companyReportingWebServiceSoap"> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> 

    <wsdl:operation name="PostHours"> 
    <soap:operation soapAction="http://company.net/ForStandardReport" style="rpc"/> 
    <wsdl:input name="ForStandardReport"> 
    <soap:body use="encoded" namespace="http://company.net/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </wsdl:input> 
    <wsdl:output name="ForStandardReport"> 
    <soap:body use="encoded" namespace="http://company.net/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </wsdl:output> 
    </wsdl:operation> 
    <wsdl:operation name="PostHours"> 
    <soap:operation soapAction="http://company.net/ForSpecialReport" style="rpc"/> 
    <wsdl:input name="ForSpecialReport"> 
    <soap:body use="encoded" namespace="http://company.net/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </wsdl:input> 
    <wsdl:output name="ForSpecialReport"> 
    <soap:body use="encoded" namespace="http://company.net/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </wsdl:output> 
    </wsdl:operation> 

</wsdl:binding> 

<wsdl:binding name="companyReportingWebServiceSoap12" type="tns:companyReportingWebServiceSoap"> 
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> 
    <wsdl:operation name="PostHours"> 
    <soap12:operation soapAction="http://company.net/ForStandardReport" style="rpc" soapActionRequired="true"/> 
    <wsdl:input name="ForStandardReport"> 
    <soap12:body use="encoded" namespace="http://company.net/" encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> 
    </wsdl:input> 
    <wsdl:output name="ForStandardReport"> 
    <soap12:body use="encoded" namespace="http://company.net/" encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> 
    </wsdl:output> 
    </wsdl:operation> 
    <wsdl:operation name="PostHours"> 
    <soap12:operation soapAction="http://company.net/ForSpecialReport" style="rpc" soapActionRequired="true"/> 
    <wsdl:input name="ForSpecialReport"> 
    <soap12:body use="encoded" namespace="http://company.net/" encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> 
    </wsdl:input> 
    <wsdl:output name="ForSpecialReport"> 
    <soap12:body use="encoded" namespace="http://company.net/" encodingStyle="http://www.w3.org/2003/05/soap-encoding"/> 
    </wsdl:output> 
    </wsdl:operation> 
</wsdl:binding> 

<wsdl:service name="companyReportingWebService"> 
<wsdl:port name="companyReportingWebServiceSoap" binding="tns:companyReportingWebServiceSoap"> 
<soap:address location="http://reportingservice.services.company.net/ReportingService.asmx"/> 
</wsdl:port> 
<wsdl:port name="companyReportingWebServiceSoap12" binding="tns:companyReportingWebServiceSoap12"> 
<soap12:address location="http://reportingservice.services.company.net/ReportingService.asmx"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

這是我在PHP代碼來調用Web服務:

<?php 
//webservice definition 
$WebService="http://reportingservice.services.company.net/ReportingService.asmx?wsdl"; 
//parameters definition 
$parameters = array(); 
$parameters['CallVendorCode'] = 'code'; 
$parameters['CallDate'] = '01/01/2014'; 
$parameters['BTNState'] = 'code'; 
$parameters['PromotionCode'] = 'cod'; 
$parameters['ReportCode'] = 'code'; 
$parameters['Hours'] = 1; 
$parameters['ReportBy'] = 'code'; 

// webservice invocation 
$WS = new SoapClient($WebService); 

// method response in object 
$result = $WS->__soapCall('PostHours',$parameters); 

//result 
print_r($result); 


?> 

它適用於標準的行動,但對於其他操作不工作,即使我添加的SOAPAction的選項,在__soapCall

$result = $WS->__soapCall('PostHours',$parameters,array('soapaction' => 'http://company.net/ForSpecialReport')); 

回答

0

這應該這樣做:

$wsdl = 'http://reportingservice.services.company.net/ReportingService.asmx?wsdl'; 
$client = new SoapClient($wsdl); 

//parameters definition 
$parameters = array(); 
$parameters['CallVendorCode'] = 'code'; 
$parameters['CallDate'] = '01/01/2014'; 
$parameters['BTNState'] = 'code'; 
$parameters['PromotionCode'] = 'cod'; 
$parameters['ReportCode'] = 'code'; 
$parameters['Hours'] = 1; 
$parameters['ReportBy'] = 'code'; 

$responseStandardReport = $client->ForStandardReport($parameters); 
//or 
$responseSpecialReport = $client->ForSpecialReport($parameters); 

//AND 

$resultStandardReport = $responseStandardReport->ForStandardReportResult; 
//or 
$resultSpecialReport = $responseSpecialReport->ForStandardReportResult; 
+0

功能I'm調用時PostHours不ForSecialReport不過這個功能有2個動作ForStandardReport和ForSpecialReport,我不知道如何在這2次肥皂的行動選擇,請檢查xml的服務 –