我创建了一个WCF服务,我有两个端点,一个用于wsHttpBinding,另一个用于basicHttpBinding。我可以使用wsHttpBinding和basicHttpBinding,只需使用ASP.Net调用即可。
我在尝试用php使用basicHttpBinding服务时遇到了问题。
这是元数据。
<wsdl:definitions name="PURLService" targetNamespace="http://xxx.xxx.com/TMServices/">
<wsdl:import namespace="http://tempuri.org/" location="http://xxx.xxx.com/TMServices/PURLServ.svc?wsdl=wsdl1"/>
<wsdl:types/>
<wsdl:service name="PURLService">
<wsdl:port name="WSHttpBinding_ITMService" binding="i0:WSHttpBinding_ITMService">
<soap12:address location="http://xxx.xxx.com/TMServices/PURLServ.svc/ws"/>
<wsa10:EndpointReference>
<wsa10:Address>http://xxx.xxx.com/TMServices/PURLServ.svc/ws</wsa10:Address>
<Identity>
<Spn>host/xxx.xxx.com</Spn>
</Identity>
</wsa10:EndpointReference>
</wsdl:port>
<wsdl:port name="BasicHttpBinding_ITMService" binding="i0:BasicHttpBinding_ITMService">
<soap:address location="http://xxx.xxx.com/TMServices/PURLServ.svc/basic"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>当我试图通过在php上提供地址http://xxx.xxx.com/TMServices/PURLServ.svc/basic来调用basicHttpBinding端点时,我得到了以下错误:"SOAP- error : Parsing WSDL: call‘t load from 'http://xxx.xxx.com/TMServices/PURLServ.svc/basic’:failed to load external entity“
这是php代码:
$wsdl = "http://xxx.xxx.com/TMServices/PURLServ.svc/basic";
try {
$client = new SoapClient($wsdl);
$result = $client->TestServices(); //this should return true if accessed
print $result;
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>此外,我不能直接访问http://xxx.xxx.com/TMServices/PURLServ.svc/basic,我得到了一个400错误的请求错误。
当我尝试在php代码上使用http://xxx.xxx.com/TMServices/PURLServ.svc?wsdl地址时,我得到了以下错误:“无法处理消息,因为内容类型'text/xml;charset=utf-8‘不是预期的类型'application/soap+xml;charset=utf-8’。”
我很感谢你的帮助。
发布于 2011-07-13 01:41:33
尝试直接转到服务(http://xxx.xxx.com/TMServices/PURLServ.svc)页面。有可能是你的服务中有一个问题,正在阻止它加载,当你试图浏览它时,你应该知道它是什么。
我的记忆很模糊,但我似乎记得在过去看到过类似的行为(“无法处理消息,因为内容类型'text/xml;charset=utf-8‘不是预期的类型'application/soap+xml;charset=utf-8’。”)当我遇到服务无法加载的问题时。
发布于 2011-08-17 15:59:30
首先,确保您的WCF服务和PHP客户端在basicHttpBinding上使用相同版本的SOAP协议(1.1)。
通过引用WSDL文件创建PHP客户端。
例如:
// Create a new soap client based on the service's metadata (WSDL)
$client = new SoapClient("http://localhost:8731/FileUploadService?wsdl")至于字符集错误(UTF-8),您可以指示PHP客户端应该使用哪个字符集:
$client->soap_defencoding = 'UTF-8';https://stackoverflow.com/questions/6666713
复制相似问题