how to call my asp.net web service from php?
17,613
This code is working fine for me...
<?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);
?>
Author by
Saravanan
I am Saravanan MCA Graduate.I am working as a Senior Developer in java environment. Email:[email protected]
Updated on June 14, 2022Comments
-
Saravanan almost 2 years
I have one web service created in asp.net and published in iis 5.1 .Now i want to call this web service from php environment. Actually my web service get one string as a parameter and return the same string .But all the time, the returned string is empty or null.I could not able to send string value from php to asp.net web service...
This is my web service created in asp.net
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; } } }
And, this is my php code for calling the above asp.net web service...
<?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"; } ?>
I don't know whether the changes needed in php side or asp.net side?...Please guide me to get out of this issue...