473,830 Members | 2,210 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 21012
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
1883
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
2529
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
10087
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
3592
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
17126
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
6000
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
1177
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
1763
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
3768
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
9640
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
10768
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
10475
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
10196
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...
0
9309
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7739
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
6940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.