PHP 调用asp.net Web Services服务问题总结
2014-03-30 15:52
666 查看
自己写的代码
<html>
<head>
<title>
测试页面
</title>
</head>
<a href="http://wwww.baidu.com">百度</a>
<?php
(一)
$soap = new SoapClient("http://localhost:8035/Service1.svc?wsdl");
$sum = $soap->GetData(array('value'=>5));
foreach ($sum as $s) {
echo $s;
}
(二)
$soap = new SoapClient("http://localhost:8035/Service1.svc?wsdl");
$myStrs="";
$sum = $soap->isExistUser(array ('UserName'=>'admin1','PassWord'=>'e00cf25ad42683b3df678c61f42c6bda','visitAdress'=>'127.0.0.1'));
foreach ($sum as $s) {
echo $s;
$myStrs=$s;
}
echo '</br>';
echo $myStrs;
echo strlen($myStrs);
echo '</br>';
//$test1="'{\"nu\":".$s."}'";
$myStr123=substr($myStrs,1,strlen($myStrs)-2);
echo $myStr123;
$obj1=json_decode($myStr123);
echo $obj1->UserID;
echo '</br>';
echo '</br>';
//echo $sum->UserID;
$str = '{"UserID":"2"}';
$obj1=json_decode($str);
echo $obj1->UserID;
echo '</br>';
$json_string='{"id":1,"name":"foo","email":"foo@foobar.com","interest":["wordpress","php"]} ';
$obj=json_decode($json_string);
echo $obj->name; //prints foo
echo "</br>";
echo $obj->interest[1]; //prints php
?>
<a href="mysecond.php?id=25">测试页面</a>
</html>
参考:
PHP 调用jave asp.net Web Services服务问题总结
Catchable fatal error: Object of class stdClass could not be converted to string in ...
PHP是弱类型语言,转换非常不方便。
< ?php
//soap 客户端
$client=new SoapClient('http://localhost:1278/WebSite1/WebService.asmx?WSDL');
$hello = $client->HelloWorld();
echo $hello;//不可以直接输出会有以下错误提示,但在Java下却正常。
//必须采用以下循环输出即可
foreach ($hello as $h)
{
echo $h;
}
?>
调用多个参数
$sum = $client->Sun(array('a'=>5,'b'=>85));
foreach ($sum as $s) {
echo $s;
}
C#:
[WebMethod]
public String Sun(Int32 a ,Int32 b)
{
return a + b+"";
}
//另一种调用方法
$sum = $client->__call('Sun',array('parameters'=>array('a'=>4,'b'=>4)));
foreach ($sum as $s) {
echo $s;
}
服务器端编写:
访问: http://localhost/index.php?wsdl
http://blog.sina.com.cn/s/blog_4beab9e201015l8f.html
<html>
<head>
<title>
测试页面
</title>
</head>
<a href="http://wwww.baidu.com">百度</a>
<?php
(一)
$soap = new SoapClient("http://localhost:8035/Service1.svc?wsdl");
$sum = $soap->GetData(array('value'=>5));
foreach ($sum as $s) {
echo $s;
}
(二)
$soap = new SoapClient("http://localhost:8035/Service1.svc?wsdl");
$myStrs="";
$sum = $soap->isExistUser(array ('UserName'=>'admin1','PassWord'=>'e00cf25ad42683b3df678c61f42c6bda','visitAdress'=>'127.0.0.1'));
foreach ($sum as $s) {
echo $s;
$myStrs=$s;
}
echo '</br>';
echo $myStrs;
echo strlen($myStrs);
echo '</br>';
//$test1="'{\"nu\":".$s."}'";
$myStr123=substr($myStrs,1,strlen($myStrs)-2);
echo $myStr123;
$obj1=json_decode($myStr123);
echo $obj1->UserID;
echo '</br>';
echo '</br>';
//echo $sum->UserID;
$str = '{"UserID":"2"}';
$obj1=json_decode($str);
echo $obj1->UserID;
echo '</br>';
$json_string='{"id":1,"name":"foo","email":"foo@foobar.com","interest":["wordpress","php"]} ';
$obj=json_decode($json_string);
echo $obj->name; //prints foo
echo "</br>";
echo $obj->interest[1]; //prints php
?>
<a href="mysecond.php?id=25">测试页面</a>
</html>
参考:
PHP 调用jave asp.net Web Services服务问题总结
Catchable fatal error: Object of class stdClass could not be converted to string in ...
PHP是弱类型语言,转换非常不方便。
< ?php
//soap 客户端
$client=new SoapClient('http://localhost:1278/WebSite1/WebService.asmx?WSDL');
$hello = $client->HelloWorld();
echo $hello;//不可以直接输出会有以下错误提示,但在Java下却正常。
//必须采用以下循环输出即可
foreach ($hello as $h)
{
echo $h;
}
?>
调用多个参数
$sum = $client->Sun(array('a'=>5,'b'=>85));
foreach ($sum as $s) {
echo $s;
}
C#:
[WebMethod]
public String Sun(Int32 a ,Int32 b)
{
return a + b+"";
}
//另一种调用方法
$sum = $client->__call('Sun',array('parameters'=>array('a'=>4,'b'=>4)));
foreach ($sum as $s) {
echo $s;
}
服务器端编写:
访问: http://localhost/index.php?wsdl
http://blog.sina.com.cn/s/blog_4beab9e201015l8f.html
相关文章推荐
- PHP 调用asp.net Web Services服务问题总结
- PHP 调用asp.net Web Services服务问题总结
- 每日学习总结:CSS:Clear属性的用法、重复交易提示框、弹出提示框后页面变形、asp.net调用smtp服务发送邮件问题
- 每日学习总结:CSS:Clear属性的用法、重复交易提示框、弹出提示框后页面变形、asp.net调用smtp服务发送邮件问题
- ASP.NET 状态服务 及 session丢失问题解决方案总结[转]
- ASP.NET状态服务及session丢失问题解决方案总结
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- ASP.NET 状态服务 及 session丢失问题解决方案总结
- AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- [导入]ASP.NET 状态服务 及 丢失问题解决方案总结
- ASP.NET 状态服务 及 session丢失问题解决方案总结
- PHP通过传递对象参数调用asp.net Webservice 服务
- ASP.NET 状态服务 及 session丢失问题解决方案总结
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- ASP.NET状态服务及session丢失问题解决方案总结
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案
- 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案