NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Nusoap is eating my array!!


Joined: 05 Nov 2009
Posts: 4
Reply with quote
Hi

Total noob to nusoap, soap, wsdl etc Wink

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:

Code:

<?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]

Code:

$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!

Code:

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.
View user's profileFind all posts by darkgr33nSend private message


Joined: 05 Nov 2009
Posts: 4
Reply with quote
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:

Code:

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!

Code:

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
View user's profileFind all posts by darkgr33nSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
you're wrong if you think you can pass arbitrary arguments to soap function. You have to follow specification in your wsdl file. Please check it and fix the call.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 05 Nov 2009
Posts: 4
Reply with quote
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?
View user's profileFind all posts by darkgr33nSend private message


Joined: 05 Nov 2009
Posts: 4
Reply with quote
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:

Code:


<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!

Code:


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:

Code:

<?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:

Code:

<?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
View user's profileFind all posts by darkgr33nSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
you may want to validate the formed REQUEST against gas.com schema. Try any validating xml editor to do this.
To me UFT-8 and < Default > are two incorrect parts.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
hi


Joined: 12 Jan 2010
Posts: 2
Reply with quote
One more thing i used mysql_free_results function to free the memory in my code.
that is where i dont know too

















View user's profileFind all posts by asd123Send private message


Joined: 03 Feb 2011
Posts: 1
Reply with quote
Hello,

I'm having a similar problem, where there is no data in the body tags of the Request created by NuSoap.

See my source code below.

Any help is appreciated!

Thanks!

---------------
Source Code:

$wsdl = $stamps["wsdl"];

$arrParameters_Login = array('AuthenticateUser' =>
array('Credentials' =>
array( 'IntegrationID' => "A47656D-D567B-47-A330-E134325493CF",
'Username' => "username",
'Password' => "password")));

$soapclient = new soapclient("https://swsim.testing.stamps.com/swsim/swsimv10.asmx?WSDL","wsdl");

$AuthUser = $soapclient->call('AuthenticateUser', $arrParameters_Login);

echo "<br /> REQUEST: " . $soapclient->request;
echo "<br /> RESPONSE: " . $soapclient->response;

exit();

-------------------------

Resulting NuSoap REQUEST:

POST /swsim/swsimv10.asmx HTTP/1.0

User-Agent: NuSOAP/0.6.7 (1.73)

Host: swsim.testing.stamps.com

Content-Type: text/xml; charset=ISO-8859-1

SOAPAction: "http://stamps.com/xml/namespace/2010/09/swsim/swsimv10/AuthenticateUser"

Content-Length: 455



<?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:si="http://soapinterop.org/xsd"><SOAP-ENV:Body><AuthenticateUser xmlns="http://stamps.com/xml/namespace/2010/09/swsim/swsimv10"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
View user's profileFind all posts by slouchSend private message
Nusoap is eating my array!!
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  

  
  
 Reply to topic