473,714 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Consuming .Net WebService with PHP and NuSOAP

amine
2 New Member
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 21001
bmiller264
1 New Member
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
dejikadri
2 New Member
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
dejikadri
2 New Member
use this. it worked for me

$params =array( 'parametername' => 'amine' );
$result = $client->call("sayHello ", array('paramete rs' => $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 Recognized Expert Specialist
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
heshanmw
1 New Member
This also may hepfull to you

using NuSoap: consume a .NET web service in 10 min | HEIDI Software
Nov 28 '08 #6
jacanon7
1 New Member
Hello

I did two web services manageSession.a smx and manageStaff.asm x

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
1881
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 ( python ) where he does some stuff with it and than normally returns "ok" the code below works , but instead of the contents of the files $Code_xxx_Contents I putted a fixed string. if i try to put the name of the varialbe i don't get the wanted...
0
2525
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 of complex datatypes to the WSDL webservice. This is the request-structure we've been using: <EzCreateAuctionArray xmlns=http://www.blabla.com>
6
10076
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 webservice that will receive an xml file with all the data to update an encrypted database. This way all database logic will remain on the Linux server. The web service works OK using a testing PHP client.
1
3587
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 existence for web services. I have three function:
5
17120
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
5996
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 = proxyObject; It doesn't works, it returns a error HTTP 407: Proxy Authentication Required ( Access is denied. ). But my proxy don't need a user Authentication.
0
1171
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 is using ASP... As I have only experiences with the setup of PHP webservice, I don't know where to start... Is there any ASP lib available? Or how does it work? Thanks for any hints!
1
1761
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 is using ASP... As I have only experiences with the setup of PHP webservice, I don't know where to start... Is there any ASP lib available? Or how does it work? Thanks for any hints!
3
3761
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 'includes/nusoap.php'; $params = array('CardId' => 'sm_stu_id_001', 'DeviceIp' => '192.168.60.68' ); $client = new nusoap_client('testWebService.php',false); //+++++++++++++++++++++++++++++++++++++
0
8808
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8712
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9316
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6637
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4727
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.