Home > php教程 > php手册 > PHP中调用ASP.NET的WebService的代码

PHP中调用ASP.NET的WebService的代码

WBOY
Release: 2016-06-06 20:36:43
Original
1013 people have browsed it

创建一个C#的web service,这个就不多说了,我用vs2008的wizard创建了一个最简单的,让它运行在:http://localhost/webservice1/service1.asmx

其中有个web method像这样的:
代码如下:
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}

ok,一切就绪。在某php文件中如下写法:
php5本身就支持SOAP调用Web Service:
代码如下:
//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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template