码迷,mamicode.com
首页 > Web开发 > 详细

PHP通过传递对象参数调用asp.net服务测试

时间:2014-12-29 13:33:58      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

asp.net 测试服务

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

 

PHP通过传递对象参数调用asp.net服务测试

标签:

原文地址:http://www.cnblogs.com/lonelyxmas/p/4191391.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!