|
| Nusoap is eating my array!! | |
Joined: 05 Nov 2009 |
Posts: 4 |
|
|
|
Posted: Wed Nov 04, 2009 2:09 pm |
|
|
|
|
|
Hi
Total noob to nusoap, soap, wsdl etc
I'm passing an array to nusoap, but it just totally ignores it, and I don't understand why, perhaps someone here would point me in the right direction.
Running PHP 5.1.4
My SOAP Request need to replicate the example below:
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<QASearch xmlns="http://www.qas.com/web-2005-10">
<Country>GBR</Country>
<Engine Flatten="true">Authenticate</Engine>
<Layout>< Default ></Layout>
<QAConfig />
<SearchSpec>
<SearchTerm Key="CTRL_SEARCHCONSENT">Yes</SearchTerm>
<SearchTerm Key="NAME_FORENAME">john</SearchTerm>
<SearchTerm Key="NAME_SURNAME">smith</SearchTerm>
<SearchTerm Key="NAME_DATEOFBIRTH">01/01/1999</SearchTerm>
<SearchTerm Key="ADDR_HOUSENAME">George West House</SearchTerm>
<SearchTerm Key="ADDR_HOUSENUMBER">2-3</SearchTerm>
<SearchTerm Key="ADDR_STREET">Clapham Common North Side</SearchTerm>
<SearchTerm Key="ADDR_TOWN">LONDON</SearchTerm>
<SearchTerm Key="ADDR_POSTCODE">SW4 0QL</SearchTerm>
</SearchSpec>
</QASearch>
</soapenv:Body>
</soapenv:Envelope>
|
I construct my array, as follows [this works with the php soapclient]
$authenticate = array(
'Country' => 'GBR',
'Engine' => array ('_' => 'Authenticate', 'Flatten' => true, 'PromptSet' => 'Default'),
'Layout' => '< Default >',
'SearchSpec' => array(
array('_' => 'Yes', 'Key' => 'CTRL_SEARCHCONSENT'),
array('_' => 'john', 'Key' => 'NAME_FORENAME'),
array('_' => 'smith', 'Key' => 'NAME_SURNAME'),
array('_' => '01/01/1999', 'Key' => 'NAME_DATEOFBIRTH'),
array('_' => 'George West House', 'Key' => 'ADDR_HOUSENAME'),
array('_' => '2-3', 'Key' => 'ADDR_HOUSENUMBER'),
array('_' => 'Clapham Common North Side', 'Key' => 'ADDR_STREET'),
array('_' => 'London', 'Key' => 'ADDR_TOWN'),
array('_' => 'SW4 0QL', 'Key' => 'ADDR_POSTCODE')
)
);
|
And I call the client, like this:
require_once ('../nusoap/lib/nusoap.php');
$wsdlfile = "authenticate.wsdl";
$client = new nusoap_client ($wsdlfile,'wsdl');
$repsonse = $client->call('DoSearch',$authenticate);
But the SOAP Request is formatted without any data at all!
REQUEST :
POST / HTTP/1.0 Host: Sbsswhapp006:2021 User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "http://www.qas.com/web-2005-10/DoSearch" Content-Length: 414 <?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
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/"
xmlns:ns6316="http://tempuri_org">
<SOAP-ENV:Body>
<QASearch xmlns="http://www.qas.com/web-2005-10"/></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
Any help getting me going on this would be really appreciated, thanks.
|
|
|
| | |
Joined: 05 Nov 2009 |
Posts: 4 |
|
|
|
Posted: Thu Nov 05, 2009 6:05 am |
|
|
|
|
|
hmm, I thought it may be the complex array that was causing me problems, but turns out, even the simplest array falls over. I just don't understand why its so difficult to get anything out of nusoap. i must be missing something fundamental here. Look:
require_once ('../nusoap/lib/nusoap.php');
$client = new nusoap_client("authenticate.wsdl", 'wsdl');
$response_doCanSearch = $client->call('DoCanSearch',array('Country'=>'GBR'));
echo("<br />REQUEST :<br />" . htmlspecialchars($client->request,ENT_QUOTES) . "<br />");
|
gives absolutely no data between the body tags. I seem to be going backwards!
REQUEST :
POST / HTTP/1.0 Host: xxxxxxx:2021 User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=UFT-8 SOAPAction: "http://www.qas.com/web-2005-10/DoCanSearch" Content-Length: 412 <?xml version="1.0" encoding="UFT-8"?><SOAP-ENV:Envelope 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/" xmlns:ns4543="http://tempuri_org"><SOAP-ENV:Body><QACanSearch xmlns="http://www.qas.com/web-2005-10"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
Any ideas ? This must be simpler that this, surely!
Thanks
|
|
|
| | |
|
| | |
Joined: 05 Nov 2009 |
Posts: 4 |
|
|
|
Posted: Fri Nov 06, 2009 6:02 am |
|
|
|
|
|
Hi Dmitri
Thanks for your reply.
I'm obviously doing something fundamentally wrong, but I don't know how to follow the specs in WSDL file. The way I pass it work with the PHP soapclient [although it fails for something else], and the examples I've seen seem to show that its done this way.
You can see in the first example how the SOAP Request should be made - are you able to help me out how I would construct it correctly based on that - thats the example I was given and told to replicate - or should I post the relevant part of the WSDL file - the QASearch function ?
Looking at the Google API example in the sticky, I seem to be doing it the same way [although not sure what the correct urn:GoogleSearch equivalent is, but I've tried a lot!].
The Google example:
You set the $paramaters array.
Set a new client:
$soapclient = new soapclient('http://api.google.com/GoogleSearch.wsdl', 'wsdl');
Then make the call:
$results = $soapclient->call('doGoogleSearch',$parameters,'urn:GoogleSearch');
My example seems to do the same:
I set the $authenticate array.
Set the new client:
$client = new nusoap_client($wsdlfile,'wsdl');
Then make the call:
$response_doAuthenticate = $client->call('DoSearch',$authenticate,'urn:QASearch');
[not sure about the urn:, i'm not sure how this is derived, but there is an element in the WSDL called that, which is the method I should be using. but i have tried a few things. some examples i've seen don't seem to include that?
|
|
|
| | |
Joined: 05 Nov 2009 |
Posts: 4 |
|
|
|
Posted: Fri Nov 06, 2009 1:20 pm |
|
|
|
|
|
I can't work out how to use an array for this (?!) so am settling for sending the XML in a variable.Here's the relevant parts of the WSDL
WSDL:
<definitions
name="QAS" targetNamespace="http://www.qas.com/web-2005-10"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:qas="http://www.qas.com/web-2005-10">
<types>
<xs:schema
elementFormDefault="qualified"
targetNamespace="http://www.qas.com/web-2005-10"
xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="QASearch">
<xs:complexType>
<xs:sequence>
<xs:element name="Country" type="qas:ISOType" />
<xs:element name="Engine" type="qas:EngineType" />
<xs:element name="Layout" type="xs:string" minOccurs="0" />
<xs:element name="QAConfig" type="qas:QAConfigType" minOccurs="0" />
<xs:element name="Search" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="SearchSpec" type="qas:SearchType" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
ISO:
<xs:simpleType name="ISOType">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z][A-Za-z][A-Za-z]" />
</xs:restriction>
</xs:simpleType>
ENGINE:
<xs:simpleContent>
<xs:extension base="qas:EngineEnumType">
<xs:attribute name="Flatten" type="xs:boolean" />
<xs:attribute name="Intensity" type="qas:EngineIntensityType" />
<xs:attribute name="PromptSet" type="qas:PromptSetType" />
<xs:attribute name="Threshold" type="qas:ThresholdType" />
<xs:attribute name="Timeout" type="qas:TimeoutType" />
</xs:extension>
</xs:simpleContent>
<xs:simpleType name="EngineEnumType">
<xs:restriction base="xs:string">
<xs:enumeration value="Singleline" />
<xs:enumeration value="Typedown" />
<xs:enumeration value="Verification" />
<xs:enumeration value="Authenticate" />
</xs:restriction>
</xs:simpleType>
SEARCHTERM:
<xs:complexType name="SearchType">
<xs:sequence>
<xs:element name="SearchTerm" type="qas:SearchTerm" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="SearchTerm">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Key" type="xs:string" default="1" />
<xs:attribute name="Index" type="xs:positiveInteger" default="1" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
|
Using the following PHP, I get the Request below, but see the Response. I just can't see what's invalid about my parameters. I've been on this for 10 days now!
require_once ('../nusoap/lib/nusoap.php');
$wsdlfile = "http://mywebserver/authenticate.wsdl";
$client = new nusoap_client($wsdlfile,'wsdl');
$soapXML = '<QASearch xmlns="http://www.qas.com/web-2005-10"><Country>GBR</Country><Engine Flatten="true" PromptSet="Default">Authenticate</Engine><Layout>< Default ></Layout><SearchSpec><SearchTerm Key="CTRL_SEARCHCONSENT">Yes</SearchTerm><SearchTerm Key="NAME_FORENAME">john</SearchTerm><SearchTerm Key="NAME_SURNAME">smith</SearchTerm><SearchTerm Key="NAME_DATEOFBIRTH">01/01/1999</SearchTerm><SearchTerm Key="ADDR_HOUSENAME">George West House</SearchTerm><SearchTerm Key="ADDR_HOUSENUMBER">2-3</SearchTerm><SearchTerm Key="ADDR_STREET">Clapham Common North Side</SearchTerm><SearchTerm Key="ADDR_TOWN">LONDON</SearchTerm><SearchTerm Key="ADDR_POSTCODE">SW4 0QL</SearchTerm></SearchSpec></QASearch>';
$response_doAuthenticate = $client->call('DoSearch',$soapXML,'http://www.qas.com/web-2005-10','http://www.qas.com/web-2005-10/DoSearch');
|
REQUEST formed:
<?xml version="1.0" encoding="UFT-8"?>
<SOAP-ENV:Envelope
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/" xmlns:qas="http://www.qas.com/web-2005-10">
<SOAP-ENV:Body>
<QASearch xmlns="http://www.qas.com/web-2005-10">
<Country>GBR</Country>
<Engine Flatten="true" PromptSet="Default">Authenticate</Engine>
<Layout>< Default ></Layout>
<SearchSpec>
<SearchTerm Key="CTRL_SEARCHCONSENT">Yes</SearchTerm>
<SearchTerm Key="NAME_FORENAME">john</SearchTerm>
<SearchTerm Key="NAME_SURNAME">smith</SearchTerm>
<SearchTerm Key="ADDR_HOUSENAME">George West House</SearchTerm>
<SearchTerm Key="ADDR_HOUSENUMBER">2-3</SearchTerm>
<SearchTerm Key="ADDR_STREET">Clapham Common North Side</SearchTerm>
<SearchTerm Key="ADDR_TOWN">LONDON</SearchTerm>
<SearchTerm Key="ADDR_POSTCODE">SW4 0QL</SearchTerm>
</SearchSpec>
</QASearch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
RESPONSE:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>-4600</faultstring>
<detail>Failed to parse or validate XML against the schema; invalid parameters</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
|
If anyone can see anything wrong and point me in the right direction, I'd be eternally grateful.
Thanks
|
|
|
| | |
| hi | |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 1
|
|
|
| |