Connecting Tech Pros Worldwide Forums | Help | Site Map

consuming a .net web service using php

Newbie
 
Join Date: Mar 2008
Posts: 3
#1: Mar 5 '08
Hi,
I am trying to access a .net web service using php.A member function in the web service has an object as a parameter.
I was not able to access that member function.
Here is the web service coding..
Expand|Select|Wrap|Line Numbers
  1. public MemberView ChangeEmailAddress(InfiSession infiSes, string oldEmailAddress, string newEmailAddress)
  2.         {
  3.             try
  4.             {
  5.                 MemberManager memberManager = new MemberManager(infiSes);
  6.                 Member mem = memberManager.ChangeEmailAddress(infiSes.MemberId, oldEmailAddress, newEmailAddress);
  7.                 MemberView memView = memberManager.GetMemberViewByEmailAddress(mem.EmailAddress);
  8.                 return (memView);
  9.             }
  10.             catch (Exception ex)
  11.             {
  12.                 InfiDebugLog.AppServer.WriteError(ex);
  13.                 throw FaultUtility.GetFaultException(ex);
  14.             }
  15.         }
  16.  
  17. I am trying to access the above member function ChangeEmailAddress.
  18. For that i have to pass 3 parameters 1.an object 2.old email address 3.new email address.
  19.  
  20. Here is my php coding...
  21.  
  22. <?php
  23. ob_start();
  24. session_start();
  25. require_once('nusoap.php');
  26. $client = new nusoap_client('http://n1app1exc.corp.lan:8082/MemberService.svc?wsdl', 'wsdl'); 
  27.  
  28. $err = $client->getError();
  29.  
  30. //$memberid =($client->"InfiSession.infiSes");
  31. if ($err) {
  32.     echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  33. }
  34.  
  35. $client->soap_defencoding = 'UTF-8';
  36. $client->setHTTPEncoding('deflate, gzip');
  37.  
  38.  
  39. //ss$infiSes =new InfiSession;
  40.  
  41. $id = $infiSes =$_SESSION['mid'];
  42.  
  43.  
  44. //$memberid= $_SESSION['mid'];
  45. echo $memberid;
  46. $old = $_REQUEST['oldemail']; 
  47. $new = $_REQUEST['Newemail'];     
  48. //echo $id;
  49.  
  50. //echo $infiSes;
  51. print "<pre>";
  52. $infi=$client->call("MemberService->InfiSession()" );
  53.  
  54.  
  55.               //s  MemberService.InfiSession myInfiSession = new MemberService.InfiSession();
  56.  
  57. //var_dump($client);
  58. class InfiSession
  59. {
  60. function  getvalue()
  61.     {
  62. $_MemberId=$id;
  63. $_ContextOrgId="0";
  64. $_OrgMemberId="0";
  65. $_ServerUrl="";
  66.     }
  67. }
  68. $infiSes=new InfiSession;
  69.  
  70.  $result = $client->call('ChangeEmailAddress', array ("InfiSession infiSses" =>$infiSes,"oldEmailAddress"=>$old,"newEmailAddress" =>$new));
  71. var_dump($result);
  72. if($result['faultstring']!="")
  73. { echo $result['faultstring']['!'];
  74. }
  75. print_r($result); 
  76.  
  77. ?>
i was not able access the function..
Please help me..
I have to do this with in a week..
Thanks in advance

Riaz

Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jun 27 '08

re: consuming a .net web service using php


Heya, Riaz.

In my experience, NuSoap does not work properly with .NET webservices because .NET doesn't understand namespaces properly.

Try passing some sample XML that you know should work to your .NET server to see if that part of it is working.
Reply