Consuming .Net WebService with PHP and NuSOAP  | Newbie | | Join Date: Sep 2006 Location: Giessen;Frankfurt;Germany
Posts: 2
| |
Hello People,
I created a WebService in .NET on my machine with following methode: - <WebMethod(Description:="test")> _
-
Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
-
Return "Hello " & myName & " (" & myID & ")"
-
End Function
-
Web service works fine, I can access my function in .NET without problem.
I can also access the function using PHP and NuSOAP however I CANNOT pass the parameters, so the result of my php page is only:
"Hello ()"
hereby is some php code I'm using:
What am I doing false: - <?php
-
-
/*NuSOAP*/
-
require_once('NuSOAP/nusoap.php');
-
$proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
-
$proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
-
$proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
-
$proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
-
$client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
-
$err = $client->getError();
-
if ($err) {
-
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
-
}
-
$params = 'amine';
-
$result = $client->call("sayHello", $params);
-
// Check for a fault
-
if ($client->fault) {
-
echo '<h2>Fault</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
} else {
-
// Check for errors
-
$err = $client->getError();
-
if ($err) {
-
// Display the error
-
echo '<h2>Error</h2><pre>' . $err . '</pre>';
-
} else {
-
// Display the result
-
echo '<h2>Result</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
}
-
}
-
?>
-
| | Newbie | | Join Date: Feb 2007
Posts: 1
| | | re: Consuming .Net WebService with PHP and NuSOAP
amine,
I believe that the problem is in the way you set your parameters, they need to be set as named values and wrapped in an outer "parameters" array for .Net. -
-
$client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
-
$err = $client->getError();
-
$params = array('parameters' => array ('name' => 'amine'));
-
$result = $client->call("sayHello", $params);
-
-
| | Newbie | | Join Date: Oct 2007
Posts: 2
| | | re: Consuming .Net WebService with PHP and NuSOAP
the parameter $$params = 'amine'; must be passed as an array not a string. Quote:
Originally Posted by amine Hello People,
I created a WebService in .NET on my machine with following methode: - <WebMethod(Description:="test")> _
-
Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
-
Return "Hello " & myName & " (" & myID & ")"
-
End Function
-
Web service works fine, I can access my function in .NET without problem.
I can also access the function using PHP and NuSOAP however I CANNOT pass the parameters, so the result of my php page is only:
"Hello ()"
hereby is some php code I'm using:
What am I doing false: - <?php
-
-
/*NuSOAP*/
-
require_once('NuSOAP/nusoap.php');
-
$proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
-
$proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
-
$proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
-
$proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
-
$client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
-
$err = $client->getError();
-
if ($err) {
-
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
-
}
-
$params = 'amine';
-
$result = $client->call("sayHello", $params);
-
// Check for a fault
-
if ($client->fault) {
-
echo '<h2>Fault</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
} else {
-
// Check for errors
-
$err = $client->getError();
-
if ($err) {
-
// Display the error
-
echo '<h2>Error</h2><pre>' . $err . '</pre>';
-
} else {
-
// Display the result
-
echo '<h2>Result</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
}
-
}
-
?>
-
| | Newbie | | Join Date: Oct 2007
Posts: 2
| | | re: Consuming .Net WebService with PHP and NuSOAP
use this. it worked for me
$params =array( 'parametername' => 'amine' );
$result = $client->call("sayHello", array('parameters' => $param)); Quote:
Originally Posted by amine Hello People,
I created a WebService in .NET on my machine with following methode: - <WebMethod(Description:="test")> _
-
Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
-
Return "Hello " & myName & " (" & myID & ")"
-
End Function
-
Web service works fine, I can access my function in .NET without problem.
I can also access the function using PHP and NuSOAP however I CANNOT pass the parameters, so the result of my php page is only:
"Hello ()"
hereby is some php code I'm using:
What am I doing false: - <?php
-
-
/*NuSOAP*/
-
require_once('NuSOAP/nusoap.php');
-
$proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
-
$proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
-
$proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
-
$proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
-
$client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
-
$err = $client->getError();
-
if ($err) {
-
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
-
}
-
$params = 'amine';
-
$result = $client->call("sayHello", $params);
-
// Check for a fault
-
if ($client->fault) {
-
echo '<h2>Fault</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
} else {
-
// Check for errors
-
$err = $client->getError();
-
if ($err) {
-
// Display the error
-
echo '<h2>Error</h2><pre>' . $err . '</pre>';
-
} else {
-
// Display the result
-
echo '<h2>Result</h2><pre>';
-
print_r($result);
-
echo '</pre>';
-
}
-
}
-
?>
-
|  | Moderator | | Join Date: Jul 2006 Location: The Netherlands
Posts: 4,139
| | | re: Consuming .Net WebService with PHP and NuSOAP
This thread was hooked by a member with a new problem regarding this subject. That post has been split off this thread and is now continued in a new thread http://www.thescripts.com/forum/thread781339.html in this mforum.
moderator
| | Newbie | | Join Date: Nov 2008
Posts: 1
| | | re: Consuming .Net WebService with PHP and NuSOAP | | Newbie | | Join Date: Aug 2009
Posts: 1
| | | re: Consuming .Net WebService with PHP and NuSOAP
Hello
I did two web services manageSession.asmx and manageStaff.asmx
I consume them with nusoap, first start session, sencond try to get the staff list but it displays The session is not set, .net pages I have solved the problem but in php no.
All your help is wellcome
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|