PHP通过传递对象参数调用asp.net Webservice 服务
2014-12-29 12:09
786 查看
asp.net 测试服务
ProcessRequest.asmx文件代码
PHP 测试代码
结果:
ProcessRequest.asmx文件代码
public class ProcessRequest : System.Web.Services.WebService { [WebMethod] public Customer RegisterCustomer(Customer customer) { var obj = new Customer(); obj.Name = customer.Name +"_Return"; obj.LastName = customer.LastName + "_Return"; obj.AnotherAttribute = customer.AnotherAttribute + "_Return"; return obj; } public class Customer { public string Name { get; set; } public string AnotherAttribute { get; set; } public string LastName { get; set; } } }
PHP 测试代码
<?php header("Content-type:text/html;charset=utf-8"); ?> <?php echo "<br/>-----------PHP通过传递对象参数调用asp.net服务测试--------------<br/>"; $object = new stdClass(); $object->Name = "Test"; $object->LastName = "More tests"; $object->AnotherAttribute = "Abc"; $client = new SoapClient('http://localhost:8091/ProcessRequest.asmx?WSDL'); $result = $client->RegisterCustomer(array('customer' => $object)); print_r($result); $myObj = $result->RegisterCustomerResult; echo "<br/>Name:";
print_r($myObj->Name); ?>
结果:
-----------PHP通过传递对象参数调用asp.net服务测试-------------- stdClass Object ( [RegisterCustomerResult] => stdClass Object ( [Name] => Test_Return [AnotherAttribute] => Abc_Return [LastName] => More tests_Return ) ) Name:Test_Return
相关文章推荐
- Asp.net ajax 调用WebService 用userContext 传递不了参数的错误
- Ext.Net Js调用WebService方法以json对象传递参数
- [转]ASP.NET 2.0 AJAX中Webservice调用方法示例 (包含参数类型为DataTable的WS方法)
- ASP.NET通过Global.asax和Timer定时器 定时调用WebService 运行后台代码
- 可遇不可求的Question之Php调用WebService传递时间参数篇
- asp.net 通过代理服务器调用WebService
- ASP.net动态调用非托管DLL的参数传递问题
- asp.net调用exe并传递参数然后关闭exe
- jQuery调用WCF服务时如何传递对象参数
- asp.net调用exe并传递参数然后关闭exe
- asp.net中调用用户控件中的函数并传递参数
- ASP.NET通过Global.asax和Timer定时器 定时调用WebService 运行后台代码
- ASP.NET页面通过URL传递参数(一)(转载)
- ASP.NET通过Global.asax和Timer定时器 定时调用WebService 运行后台代码
- 在ASP.NET里通过URL传递参数得到乱码的解决方法
- ASP.NET通过Global.asax和Timer定时器 定时调用WebService 运行后台代码
- [转]ASP.NET 2.0 AJAX中Webservice调用方法示例 (包含参数类型为DataTable的WS方法)
- ASP.net动态调用非托管DLL的参数传递问题
- PHP中调用ASP.NET的WebService的代码
- asp.net(C#)函数对象参数传递的问题