Log in

View Full Version : NuSOAP, ASP, and PHP



kosi
04-03-2007, 08:21 AM
Is anybody here familiar with NuSOAP?

Well, this is my connundrum: I'm trying to access an xml web service from a company that has the worst customer service known to man. The only information I got from them was that the response will be in xml. Thereby leaving it up to me to be creative and get this response. I tried NuSOAP, but I keep getting an error message back from them that looks like this:


<HTML>
<BODY>
<Response><ErrorCode>200</ErrorCode><ErrorText>Not a valid request</ErrorText></Response>

and that doesn't fricking look like xml to me. No delcaration, and two open html and body tags. When I alerted them to it, they said "other people have gotten it to work."

I think part of the problem is that I build in php because my server is not asp enabled (and because i don't know asp) but their service is an asp file. Does anybody have any ideas?

Thanks.

Twey
04-03-2007, 10:00 AM
I think part of the problem is that I build in php because my server is not asp enabled (and because i don't know asp) but their service is an asp file.It shouldn't be.
and that doesn't fricking look like xml to me. No delcaration, and two open html and body tags.No, but it does look like an attempt at XML written by an idiot :)

How do you access it? Can you provide the code you used to generate the request?

kosi
04-06-2007, 08:54 PM
It shouldn't be.No, but it does look like an attempt at XML written by an idiot :)

How do you access it? Can you provide the code you used to generate the request?

Here's the php file:


<?php
/*
* $Id: wsdlclient3b.php,v 1.1 2004/06/15 15:38:29 snichol Exp $
*
* WSDL client sample.
*
* Service: WSDL
* Payload: rpc/encoded (params as an XML string; cf. wsdlclient3.php)
* Transport: http
* Authentication: none
*/
require_once('../lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new soapclient('http://Kunaki.com/XMLService.ASP', false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}

$params = file_get_contents("http://musicstore.jasonkosi.com/xml_temp_4.xml");

$result = $client->call('ShippingOptions', $params, $namespace, 'ShippingOptions');
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}

echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';

echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';

echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>

And here's the xml inlclude:



<Country>United States</Country>
<state_Province>NY</state_Province>
<PostalCode>10004</PostalCode>
<Product>
<ProductId>XZZ1111111</ProductId>
<Quantity>2</Quantity>
</Product>
<Product>
<ProductId>PXZZ111112</ProductId>
<Quantity>3</Quantity>
</Product>

The request is sent with the nusoap library and looks like this:



POST /XMLService.ASP HTTP/1.0
Host: Kunaki.com
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "ShippingOptions"
Content-Length: 707

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ShippingOptions><Country>United States</Country>
<state_Province>NY</state_Province>
<PostalCode>10004</PostalCode>
<Product>
<ProductId>XZZ1111111</ProductId>
<Quantity>2</Quantity>
</Product>
<Product>
<ProductId>PXZZ111112</ProductId>
<Quantity>3</Quantity>
</Product></ShippingOptions></SOAP-ENV:Body></SOAP-ENV:Envelope>



and the response looks like this:



HTTP/1.1 200 OK
Connection: close
Date: Fri, 06 Apr 2007 20:51:59 GMT
Server: Microsoft-IIS/6.0
Content-Length: 109
Content-Type: text/xml
Expires: Fri, 06 Apr 2007 04:11:59 GMT
Set-Cookie: ASPSESSIONIDCQRDQRCS=KOIHNPDDPNHDGNHIEEDEIMGH; path=/
Cache-control: private


<HTML>
<BODY>
<Response><ErrorCode>200</ErrorCode><ErrorText>Not a valid request</ErrorText></Response>