473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Consuming .Net WebService with PHP and NuSOAP

amine
2
Hello People,
I created a WebService in .NET on my machine with following methode:

Expand|Select|Wrap|Line Numbers
  1.  <WebMethod(Description:="test")> _ 
  2. Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
  3. Return "Hello " & myName & " (" & myID & ")"
  4. End Function
  5.  
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:

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2.  
  3. /*NuSOAP*/
  4. require_once('NuSOAP/nusoap.php');
  5. $proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
  6. $proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
  7. $proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
  8. $proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
  9. $client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
  10. $err = $client->getError();
  11. if ($err) {
  12. echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  13. }
  14. $params = 'amine';
  15. $result = $client->call("sayHello", $params);
  16. // Check for a fault
  17. if ($client->fault) {
  18. echo '<h2>Fault</h2><pre>';
  19. print_r($result);
  20. echo '</pre>';
  21. } else {
  22. // Check for errors
  23. $err = $client->getError();
  24. if ($err) {
  25. // Display the error
  26. echo '<h2>Error</h2><pre>' . $err . '</pre>';
  27. } else {
  28. // Display the result
  29. echo '<h2>Result</h2><pre>';
  30. print_r($result);
  31. echo '</pre>';
  32. }
  33. }
  34. ?>
  35.  
Sep 4 '06 #1
6 20981
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
  3. $err = $client->getError();
  4. $params = array('parameters' => array ('name' => 'amine'));
  5. $result = $client->call("sayHello", $params);
  6.  
  7.  
Feb 14 '07 #2
the parameter $$params = 'amine'; must be passed as an array not a string.


Hello People,
I created a WebService in .NET on my machine with following methode:

Expand|Select|Wrap|Line Numbers
  1.  <WebMethod(Description:="test")> _ 
  2. Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
  3. Return "Hello " & myName & " (" & myID & ")"
  4. End Function
  5.  
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:

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2.  
  3. /*NuSOAP*/
  4. require_once('NuSOAP/nusoap.php');
  5. $proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
  6. $proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
  7. $proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
  8. $proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
  9. $client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
  10. $err = $client->getError();
  11. if ($err) {
  12. echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  13. }
  14. $params = 'amine';
  15. $result = $client->call("sayHello", $params);
  16. // Check for a fault
  17. if ($client->fault) {
  18. echo '<h2>Fault</h2><pre>';
  19. print_r($result);
  20. echo '</pre>';
  21. } else {
  22. // Check for errors
  23. $err = $client->getError();
  24. if ($err) {
  25. // Display the error
  26. echo '<h2>Error</h2><pre>' . $err . '</pre>';
  27. } else {
  28. // Display the result
  29. echo '<h2>Result</h2><pre>';
  30. print_r($result);
  31. echo '</pre>';
  32. }
  33. }
  34. ?>
  35.  
Oct 2 '07 #3
use this. it worked for me

$params =array( 'parametername' => 'amine' );
$result = $client->call("sayHello", array('parameters' => $param));


Hello People,
I created a WebService in .NET on my machine with following methode:

Expand|Select|Wrap|Line Numbers
  1.  <WebMethod(Description:="test")> _ 
  2. Public Function sayHello(ByVal myName As String, ByVal myID As Integer) As String
  3. Return "Hello " & myName & " (" & myID & ")"
  4. End Function
  5.  
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:

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2.  
  3. /*NuSOAP*/
  4. require_once('NuSOAP/nusoap.php');
  5. $proxyhost = isset( $POST['proxyhost']) ? $POST['proxyhost'] : '';
  6. $proxyport = isset( $POST['proxyport']) ? $POST['proxyport'] : '';
  7. $proxyusername = isset( $POST['proxyusername']) ? $POST['proxyusername'] : '';
  8. $proxypassword = isset( $POST['proxypassword']) ? $POST['proxypassword'] : '';
  9. $client = new soapclient('http://localhost/myWS/myWS.asmx?wsdl', true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
  10. $err = $client->getError();
  11. if ($err) {
  12. echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  13. }
  14. $params = 'amine';
  15. $result = $client->call("sayHello", $params);
  16. // Check for a fault
  17. if ($client->fault) {
  18. echo '<h2>Fault</h2><pre>';
  19. print_r($result);
  20. echo '</pre>';
  21. } else {
  22. // Check for errors
  23. $err = $client->getError();
  24. if ($err) {
  25. // Display the error
  26. echo '<h2>Error</h2><pre>' . $err . '</pre>';
  27. } else {
  28. // Display the result
  29. echo '<h2>Result</h2><pre>';
  30. print_r($result);
  31. echo '</pre>';
  32. }
  33. }
  34. ?>
  35.  
Oct 2 '07 #4
ronverdonk
4,258 Expert 4TB
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
Mar 11 '08 #5
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
Aug 22 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arne Holderbeke | last post by:
I'm doing my final project in PHP with a Soap webservice In the client script (PHP) 3 files are read into a string these strings and the name of the 3 files need to be passed to the webservice (...
0
by: olafmol | last post by:
Hello, i have a problem using a .NET WSDL Webservice from PHP. Using both the NuSOAP lib for PHP4, and the build-in SOAP lib for PHP5 it seems that the SOAP client cannot pass a variable amount...
6
by: Carlos Lozano | last post by:
Hi, as a background I have an Windows application developed with VS 2003 (c#) that needs to transfer securely data to a MySQL database located on a Linux server. I have created a PHP...
1
by: Nattydreadlock | last post by:
Hi, I've written an ASP.Net webservice which takes somes specific .net objects. Now I want to caal this service by PHP, which normally would be possible, after all that's the main reason of...
5
by: Preben Zacho | last post by:
Anyone that has a link or description that simply as possible shows how to add a web reference to a class library in C# and consuming it? TIA PZ
4
by: Boni | last post by:
I want consuming a webserivce trough a proxy. I use this code. myService s = new myService (); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyhost:8080"); s.Proxy =...
0
by: luftikus143 | last post by:
Hi there, we have successfully running a webservice wrapped with the NuSoap.php libs since quite a while. Now, a colleague of mine in another institution would like to use this webservice. But he...
1
by: luftikus143 | last post by:
Hi there, we have successfully running a webservice wrapped with the NuSoap.php libs since quite a while. Now, a colleague of mine in another institution would like to use this webservice. But he...
3
by: aswathip | last post by:
I am doing a Webservice in PHP for the first time. I have a service named as testWebService.php and testclient.php that consumes the service. Below is my testclient.php <?php require_once...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.