Calling ASP .NET Web Service from PHP

Posted on 2009-04-22
Last Modified: 2013-12-13
Dear Experts,

I have a web service made in .NET (Code not available and it uses windows authentication) and now I need to call this web service from PHP. How can I do that. Any code sample will be a great help.

I am new in PHP.

Question by:brijbmishra
    LVL 14

    Expert Comment


    Please look at this:

    Hope this will help you.

    LVL 2

    Accepted Solution

    try something like this:

    //if you are using nusoap - otherwise comment out the below line....

    //make sure to change the url and service name in the line below
    $client = new soapclient('', true);
    // Check for an error
    $err = $client->getError();
    if ($err)
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';

    //make sure to insert your method below
    $result = $client->call('SERVERMETHOD');
    if ($client->fault)
        echo '<h2>Fault</h2><pre>';
        echo '</pre>';
    } else
        $err = $client->getError();
        if ($err)
            echo '<h2>Error</h2><pre>' . $err . '</pre>';
        } else {
            // Display the result
            echo '<h2>Result</h2><pre>';
        echo '</pre>';
    // Display the request and response
    echo '<h2>Request</h2>';
    echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2>';
    echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
    // Display the debug messages
    echo '<h2>Debug</h2>';
    echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

    Expert Comment

    Hi, I'm not sure I understand where the answered question explains calling a windows authentication protected web service from php? Can anyone clarify?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now