php consume WCF SSL SOAP Client 1.2 -
im having problems consuming wshttpbinding wcf php. tried use soap1.2 couldnt specify ws action.
i downloaded nusoap library. getting error saying webservice wouldnt accept data due type mismatch (text/xml instead of expected application/soap+xml). managed make changes nusoap.php send data application/soap+xml). doesnt throw error, 400 bad request error server.
i can consume service wcftestclient , soapui without messing around, cannot fly php. copied entire soap envelope soapui , set $soapmsg in nusoap.php , still fails.
so want offer guidance.
edit code trying in soap 1.2
$params = array("soap_version"=> soap_1_2, "trace"=>1, "exceptions"=>0, ); $client = @new soapclient('https://localhost/wcftest/service.svc?wsdl',$params); $retval = $client->getdata(array('value'=>'stuff')); if (is_soap_fault($retval)) { trigger_error("soap fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", e_user_error); }
edit #2 code works out of soapui
<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:action>http://tempuri.org/iservice/getdata</wsa:action></soap:header> <soap:body> <tem:getdata> <!--optional:--> <tem:value>stuff</tem:value> </tem:getdata> </soap:body> </soap:envelope>
after adding soapheaders manually mentioned gords link below __last_request when debugging netbeans , still same error
"<?xml version="1.0" encoding="utf-8"?> <env:envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/"> <env:header> <ns1:action>http://tempuri.org/iservice/getdata</ns1:action> </env:header> <env:body><ns1:getdata><ns1:value>stuff</ns1:value></ns1:getdata></env:body></env:envelope>
any advice??
thanks! andy
ok got work. gord making me double check stuff had overlooked earlier on.
i ended ditching nusoap , sticking with soap 1.2. here php code
//declare paramaters our soapclient. need make sure set soap 1.2 $params = array("soap_version"=> soap_1_2, "trace"=>1, "exceptions"=>0, ); //create soap client $client = new soapclient('https://localhost/wcftest/service.svc?wsdl',$params); //add wsaddressing headers in. ensure have namespace address if using wshttpbinding on endpoint //this step took me longest figure out! $actionheader = new soapheader('http://www.w3.org/2005/08/addressing','action','http://tempuri.org/iservice/getdata',true); //add headers client $client->__setsoapheaders($actionheader); //make call , pass in variables require go server $retval = $client->__soapcall('getdata',array('value'=>'stuff')); //some error catching if (is_soap_fault($retval)) { trigger_error("soap fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", e_user_error); }
and working envelope
<?xml version="1.0" encoding="utf-8"?> <env:envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="http://www.w3.org/2005/08/addressing"> <env:header> <ns2:action env:mustunderstand="true">http://tempuri.org/iservice/getdata</ns2:action> </env:header> <env:body> <ns1:getdata/> </env:body> </env:envelope>
and web.config file wcf service
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetframework="4.0"/> </system.web> <connectionstrings> <add name="timeforce" connectionstring="data source=apps.ziptrek.com;initial catalog=qqest;user id=qqest; password=qqest;" providername="system.data.sqlclient" /> </connectionstrings> <system.servicemodel> <bindings> <wshttpbinding> <binding name="transportsecurity"> <security mode="transport"> <transport clientcredentialtype="none"/> </security> </binding> </wshttpbinding> </bindings> <services> <service name="service" behaviorconfiguration="service1"> <endpoint address="https://localhost/wcftest/service.svc" binding="wshttpbinding" bindingconfiguration="transportsecurity" contract="iservice"></endpoint> </service> </services> <behaviors> <servicebehaviors> <behavior name="service1"> <!-- avoid disclosing metadata information, set value below false , remove metadata endpoint above before deployment --> <servicemetadata httpsgetenabled="true"/> <!-- receive exception details in faults debugging purposes, set value below true. set false before deployment avoid disclosing exception information --> <servicedebug includeexceptiondetailinfaults="false"/> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="httpsservice1"> <webhttp/> </behavior> </endpointbehaviors> </behaviors> <servicehostingenvironment multiplesitebindingsenabled="false"/> </system.servicemodel> <system.webserver> <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> </configuration>
Comments
Post a Comment