PHP中调用ASP.NET的WebService的代码
程序员文章站
2022-06-03 10:42:45
其中有个web method像这样的: 复制代码 代码如下: [webmethod] public string helloworld() { return "hello...
其中有个web method像这样的:
[webmethod]
public string helloworld()
{
return "hello world";
}
ok,一切就绪。在某php文件中如下写法:
php5本身就支持soap调用web service:
<?php
//get localization strings from c# webservice
$client = new soapclient('http://localhost/webservice1/localization.asmx?wsdl');
echo "call web service method from c# webservice:\n";
$result = $client->getlocalizationresource();
if(!is_soap_fault($result))
{
echo "return:\n", $result->getlocalizationresourceresult;
}
else
{
echo "soap call fault";
}
?>
这样就ok了,会继续介绍soap
复制代码 代码如下:
[webmethod]
public string helloworld()
{
return "hello world";
}
ok,一切就绪。在某php文件中如下写法:
php5本身就支持soap调用web service:
复制代码 代码如下:
<?php
//get localization strings from c# webservice
$client = new soapclient('http://localhost/webservice1/localization.asmx?wsdl');
echo "call web service method from c# webservice:\n";
$result = $client->getlocalizationresource();
if(!is_soap_fault($result))
{
echo "return:\n", $result->getlocalizationresourceresult;
}
else
{
echo "soap call fault";
}
?>
这样就ok了,会继续介绍soap
下一篇: Photoshop制作超酷的动感啤酒海报