Calling a WCF WebService in PHP via wsHttpBinding

2019-05-09 07:07发布

问题:

I have a WCF webservice I can connect to it via basicHttp, but not wsHttp. I try to conenct to it via wshttp via the following:

$service = new SoapClient
("http://service.companyname.local:6666/Service/?wsdl",
 array(
         "location" => "http://service.companyname.local:6666/Service/WCF",

    "trace" => true,
    'soap_version' => SOAP_1_2
     )
);

The call to the SoapClient constructor returns fine. When I try to call one using $client->FunctionName, the page just sits there loading for quite a while, and eventually returns the error "Error Fetching http headers". What exactly is this supposed to mean and how do I fix it? (Consuming the service from .Net client works perfectly.)

回答1:

The default config on wsHttpBinding uses advanced WS-Security and WS-Addressing features that aren't understood by the vanilla PHP SoapClient. There are other PHP-accessible SOAP clients that might be able to work (Apache Axis2+Rampart/C, for instance), or you can try to shut off some of the incompatible wsHttpBinding features (message security is probably the first). Not to say that it won't work, but you'll probably need some trial-and-error to get it all working right.



回答2:

The last time I checked, php didn't support wsHttpBinding