Consume an ASP.NET Web Service with PHP

Last post 09-04-2009 11:02 AM by ashwinkraj. 4 replies.

Sort Posts:

  • Consume an ASP.NET Web Service with PHP

    05-24-2005, 4:09 AM
    • Member
      5 point Member
    • g.t.hill
    • Member since 05-24-2005, 8:02 AM
    • UK
    • Posts 1

    I have created a Web Service in ASP.NET and also an ASP.NET client to consume this service. The Web Service uses Windows Authentication to recognise the client, so that not just anyone can access it.

    We have another existing system built in PHP, which we would like to be able to access the ASP.NET Web Service - does anyone know how this would be possible, bearing in mind the security complications of having to authenticate the consumer?

    Any help much appreciated...

  • Re: Consume an ASP.NET Web Service with PHP

    05-24-2005, 12:29 PM
    • Contributor
      2,432 point Contributor
    • javiguillen
    • Member since 06-18-2002, 1:47 PM
    • South Florida, USA
    • Posts 523
    you may have to pass the security credentials as web service parameters. Besides that, connection to the ASP.NET service should be as easy as consuming a web service created in PHP  (consult documentation on consuming web services via PHP) 
    "Never argue with an idiot; He will drag you down to his level and beat you with experience"
  • Re: Consume an ASP.NET Web Service with PHP

    08-28-2005, 9:39 PM
    • Member
      5 point Member
    • adoniner
    • Member since 08-29-2005, 1:38 AM
    • Posts 1
    Where is this documentation on consuming .NET web services via PHP?

    ado

  • Re: Consume an ASP.NET Web Service with PHP

    07-31-2008, 4:06 AM
    • Member
      4 point Member
    • azade
    • Member since 07-31-2008, 7:32 AM
    • Posts 2

    hi,
    i create a web service with asp.net ,and then save the wsdl of it as Service.wsdl in c:\wamp\www
    (i use wamp)
    uncomment saop-php.dll in php.ini
    and use this code:
        $client = new SoapClient("Service.wsdl");
         echo "Hello";

    $param=array('name'=>'azade',);
     $result =  $client->__soapCall('HelloWorld',$param);
     print_r($result);
     
    but i got this error:
     
    Hello
    Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\wamp\www\n.php:12 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'http://tempuri....', 1, 0) #1 C:\wamp\www\n.php(12): SoapClient->__soapCall('HelloWorld', Array) #2 {main} thrown in C:\wamp\www\n.php on line 12
     
    could u help me ,plz?
    thanks

  • Re: Consume an ASP.NET Web Service with PHP

    09-04-2009, 11:02 AM
    • Member
      2 point Member
    • ashwinkraj
    • Member since 09-04-2009, 10:41 AM
    • Posts 1

    Were you able to resolve this and get PHP SOAP to talk to your .NET web service? I created a simple web service method using ASP.NET/C#

    [WebMethod]
    public int addNumbers(int num1, int num2)
    {
      int result = num1 + num2;
      TextWriter tw = new StreamWriter(@"C:\WINDOWS\Temp\addNumbers.txt");
      tw.WriteLine("" + num1 + " + " + num2 + " = " + result);
      tw.Close();

      return result;
    }

    So the input and output parameters to the method call are logged to a text file. When I test this web service method locally, it seems to work fine. But when I try to invoke it via PHP, I encounter a couple of problems -
    (a) $soapClient->addNumbers(99, 101) resulted in the text file on the server containing "0 + 0 = 0"
    (b) print $soapClient->addNumbers(99, 101); resulted in the following error on the PHP page

    Catchable fatal error:  Object of class stdClass could not be converted to string in C:\xampp\htdocs\inspect_service.php on line 27

    where line 27 is the stated line.

    Can you please help?

    Thanks.

    Ashwin

Page 1 of 1 (5 items)