Geeks With Blogs

The Life and Times of a Dev Yes, we're really that weird

So we have this affiliate that uses PHP for almost everything.  Of course, the lip we get from them is that “Linux will rule the world, microsoft will die!”

I've written a bunch of web services that basically allow them to talk directly to our system.  They're using PEAR::SOAP and NuSoap, and of course, the problem MUST be on our side.  I actually write up a telnet example that he can use.

telnet to www.mysite.com port 80 and copy and paste in exactly the following:

POST /mitwebservice/pageremoved/DatabaseSearch
HTTP/1.1 Host: www.mysite.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 230 searchParameters=(data removed for security reasons)

Of course, that doesn't make him happy.  He's still getting a parameter s is invalid, which tells him absolutely nothing.

Turns out, he had changed the namespaces on the soap request so that it didn't recognize parameters correctly.  As soon as he set them to what they should be, and passed the correct XML, it worked correctly.

Linux people drive me nuts. . .

Anyway, here's the final code that acutally worked (.net is sooooo much easier):

require_once('../../libs/nusoap.php');

$client = new soapclient('url
?WSDL',true);
$err = $client->getError();
if ($err) {
    // Display the error
    echo '

Constructor error

' . $err . '
';
    // At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('GetData', '1');
// Check for a fault
if ($client->fault) {
    echo '

Fault

';
    print_r($result);
    echo '
';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '

Error

' . $err . '
';
    } else {
        // Display the result
        echo '

Result

';
        print_r($result);
    echo '
';
    }
}
// Display the request and response
echo '

Request

';
echo '
' . htmlspecialchars($client->request, ENT_QUOTES) . '
';
echo '

Response

';
echo '
' . htmlspecialchars($client->response, ENT_QUOTES) . '
';
// Display the debug messages
echo '

Debug

';
echo '
' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
';
?>

Posted on Tuesday, December 6, 2005 7:16 AM Work | Back to top


Comments on this post: Integrating webservices with PHP

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Robert May | Powered by: GeeksWithBlogs.net