473,372 Members | 1,299 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,372 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 20972
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.