[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calling ASP .NET Web Service from PHP

Posted on 2009-04-22
3
Medium Priority
?
4,760 Views
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.

Regards
Brij
0
Comment
Question by:brijbmishra
3 Comments
 
LVL 14

Expert Comment

by:shobinsun
ID: 24203045
Hi,

Please look at this:

http://blogsandip.wordpress.com/2009/04/04/calling-aspnet-web-service-from-php/

Hope this will help you.

Regards
0
 
LVL 2

Accepted Solution

by:
JGoyer earned 2000 total points
ID: 24237820
try something like this:



//if you are using nusoap - otherwise comment out the below line....
require_once('lib/nusoap.php');

//make sure to change the url and service name in the line below
$client = new soapclient('http://www.urltoservice.com/serviceName.php?wsdl', 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>';
    print_r($result);
    echo '</pre>';
} else
{
    $err = $client->getError();
    if ($err)
   {
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
        print_r($result);
    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>';
?>
0
 

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 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