Sar*_*nan 2 .net php c# asp.net web-services
我有一个在asp.net中创建并在iis 5.1中发布的Web服务.现在我想从php环境调用这个Web服务.实际上我的web服务获取一个字符串作为参数并返回相同的字符串.但是一直,返回的字符串为空或null.我无法从php发送字符串值到asp.net web服务...
这是我在asp.net中创建的Web服务
namespace PRS_WS
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class prs_point : System.Web.Services.WebService
{
[WebMethod]
public string testAssignment(string inputData)
{
return inputData;
}
}
}
Run Code Online (Sandbox Code Playgroud)
而且,这是我调用上述asp.net Web服务的php代码...
<?php
require_once('nusoap/lib/nusoap.php');
$wsdl="http://localhost/prs_point/prs_point.asmx?WSDL";
$str1="";
$str1="Hello from php";
$client = new soapclient($wsdl,'wsdl');
$result=$client->call('testAssignment',$str1);
foreach($result as $key => $value)
{
echo "<br/>Response ::::: $value";
}
?>
Run Code Online (Sandbox Code Playgroud)
我不知道php端还是asp.net端需要进行哪些更改?...请指导我解决这个问题...
这段代码对我来说很好......
<?php
require 'nusoap/lib/nusoap.php';
$client = new nusoap_client('http://localhost/prs_point/prs_point.asmx?WSDL', 'WSDL');
$error = $client->getError();
if ($error) {
die("client construction error: {$error}\n");
}
$param = array('inputData' => 'sample data');
$answer = $client->call('testAssignment', array('parameters' => $param), '', '', false, true);
$error = $client->getError();
if ($error) {
print_r($client->response);
print_r($client->getDebug());
die();
}
print_r($answer);
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17230 次 |
| 最近记录: |