Hi

I've got a soap request which is failing, and I'm wondering if its down to the < > not being parsed correctly, as everything else looks good.

Here are the bits:

This is my request:

$authenticate = array( 
'Country' => 'GBR', 
'Engine' => array ('_' => 'Authenticate', 'Flatten' => true, 'PromptSet' => 'Default'),
'Layout' => '< Default >', 
'SearchSpec' => array(
  array('_' => 'Yes', 'Key' => 'CTRL_SEARCHCONSENT'),
  array('_' => 'MR', 'Key' => 'NAME_TITLE'),
  array('_' => 'Zuzu', 'Key' => 'NAME_FORENAME'),
  array('_' => '', 'Key' => 'NAME_INITIALS'),
  array('_' => 'Zuzu', 'Key' => 'NAME_SURNAME'),
  array('_' => '12/12/1956', 'Key' => 'NAME_DATEOFBIRTH'),
  array('_' => 'M', 'Key' => 'NAME_SEX'),
  array('_' => '', 'Key' => 'ADDR_FLAT'), 
  array('_' => '', 'Key' => 'ADDR_HOUSENAME'), 
  array('_' => '27', 'Key' => 'ADDR_HOUSENUMBER'), 
  array('_' => 'Manor Road', 'Key' => 'ADDR_STREET'), 
  array('_' => 'Alresford', 'Key' => 'ADDR_DISTRICT'), 
  array('_' => 'Zuzuchester', 'Key' => 'ADDR_TOWN'), 
  array('_' => '', 'Key' => 'ADDR_COUNTY'), 
  array('_' => 'CO4 4LT', 'Key' => 'ADDR_POSTCODE')
  )
);

and if I do a

print_r($authenticate);

I get:

Array ( 
[Country] => GBR 
[Engine] => Array ( [_] => Authenticate [Flatten] => 1 [PromptSet] => Default ) 
[Layout] => < Default > 
[SearchSpec] => Array ( 
[0] => Array ( [_] => Yes [Key] => CTRL_SEARCHCONSENT ) 
[1] => Array ( [_] => MR [Key] => NAME_TITLE ) 
[2] => Array ( [_] => Zuzu [Key] => NAME_FORENAME ) 
[3] => Array ( [_] => [Key] => NAME_INITIALS ) 
[4] => Array ( [_] => Zuzu [Key] => NAME_SURNAME ) 
[5] => Array ( [_] => 12/12/1956 [Key] => NAME_DATEOFBIRTH ) 
[6] => Array ( [_] => M [Key] => NAME_SEX ) 
[7] => Array ( [_] => [Key] => ADDR_FLAT ) 
[8] => Array ( [_] => [Key] => ADDR_HOUSENAME ) 
[9] => Array ( [_] => 27 [Key] => ADDR_HOUSENUMBER ) 
[10] => Array ( [_] => Manor Road [Key] => ADDR_STREET ) 
[11] => Array ( [_] => Alresford [Key] => ADDR_DISTRICT ) 
[12] => Array ( [_] => Zuzuchester [Key] => ADDR_TOWN )
[13] => Array ( [_] => [Key] => ADDR_COUNTY ) 
[14] => Array ( [_] => CO4 4LT [Key] => ADDR_POSTCODE ) 
) 
) 

which looks fine [thanks to johanafm and shrike]

so, I run my call as normal:

$response_doAuthenticate = $client->DoSearch($authenticate);

but, I get the error:

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 <qas:QAFault xmlns:qas="http://www.qas.com/web-2005-10"> <qas:ErrorCode>-4600</qas:ErrorCode>
<qas:ErrorMessage>Failed to parse or validate XML against the schema; invalid parameters</qas:ErrorMessage>
</qas:QAFault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope> 

when I getLastRequest(), you can see that the request has &lt; and &gt; around the Layout tag.

REQUEST:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qas.com/web-2005-10">
<SOAP-ENV:Body>
<ns1:QASearch>
<ns1:Country>GBR</ns1:Country>
<ns1:Engine Flatten="true" PromptSet="Default">Authenticate</ns1:Engine>
[B]<ns1:Layout>&lt;Default&gt;</ns1:Layout>[/B]
<ns1:SearchSpec>
<ns1:SearchTerm Key="CTRL_SEARCHCONSENT">Yes</ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_TITLE">MR</ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_FORENAME">Zuzu</ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_INITIALS"></ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_SURNAME">Zuzu</ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_DATEOFBIRTH">12/12/1956</ns1:SearchTerm>
<ns1:SearchTerm Key="NAME_SEX">M</ns1:SearchTerm>
<ns1:SearchTerm Key="ADDR_HOUSENUMBER">27</ns1:SearchTerm>
<ns1:SearchTerm Key="ADDR_STREET">Manor Road</ns1:SearchTerm>
<ns1:SearchTerm Key="ADDR_DISTRICT">Alresford</ns1:SearchTerm>
<ns1:SearchTerm Key="ADDR_TOWN">Zuzuchester</ns1:SearchTerm>
<ns1:SearchTerm Key="ADDR_POSTCODE">CO4 4LT</ns1:SearchTerm>
</ns1:SearchSpec>
</ns1:QASearch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

Is that likely to cause the problem, or am I barking up the wrong tree ?

THANKS!!

    I wouldn't be surprised if the brackets in <default> where breaking the xml in your soap request, but then the getLastRequest output suggests it has been that this probably didn't happen.

    It looks to me like you were able to formulate a request and send it to the gateway and the gateway said that it didn't understand your parameters. Are you sure the array structure you are sending conforms to what is expected by the gateway? Have you tried checking into the error message returned?

    This question might best be directed at the people operating the gateway.

      Thanks sneaky - I have done just that - directed my question at those operating the gateway. Hopefully they'll be able to shed some light on it.

      I'm pretty sure the array structure is correct, and wasn't sure if there was a way to tell the soapClient not to amend the characters, or a way of escaping them from the array into the soapClient.

      cheers

        Maybe try a different layout value just for kicks? Seems to me that might eliminate the brackets question.

          sneakyimp;10932524 wrote:

          Maybe try a different layout value just for kicks? Seems to me that might eliminate the brackets question.

          😃 ha-ha, yep, just tried that, but it still failed! Guess it means its something out of my control. Not sure what 4600 really is, or if an error is generated anywhere that is more specific.

          Tried googling the exact message - Failed to parse or validate XML against the schema; invalid parameters - but it didn't come back with much.

          will keep digging!

          thanks

            "invalid parameters" suggests to me that the structure of your array argument might not be correct but that's just a guess. If you can't get a response from the gateway folks directly, I would try to see if I could find some example code and start from that? This kind of thing can be a royal pain in my experience -- lots of trial and error. If you can get someone on the phone that usually helps.

              yep, already a right royal pain!

              Because I have multiple tags with the same name, I was struggling with getting an array to work. I expanded one that I knew worked [without multiple same names], and now have it so it seems to be contstructing valid xml .. well, according to the getLastRequest anyway, it looks ok, and matches what I'm told it should be expecting ... but it obviously isn't!

              The only slight concern is, on a couple of occasions, getLastRequest has missed out everything between the QASearch tags ... can't remember what I did for that to happen ... but ... I read somewhere that it could be a bug within PHP, not sending well-formed SOAP packets, so I tried nusoap, and I got the same error - invalid parameters - but the request also had nothing between the QASearch tags ....

              maybe something is badly formed array wise ...

                I'm a bit out of my depth here, but perhaps there's a way you could take the SOAP request and use a schema validator which might give you more information about where it's failing? Something like the w3 validator may or may not be able to tell you more than pass/fail but perhaps tell you where it breaks down? I dunno. Just a thought.

                  Out of my depth here too!

                  It turns out the reason is the soapClient object is adding ns1: to all tags, and the requirement for the Engine tag is no namespace, or qas:

                  I'm not sure if you can specify a particular namespace, or if I have to try and uniquely construct the Engine tag. More research needed!

                  So, not resolved yet, but the &lt; question is now defunct.

                    update:

                    it appears then, that I need to either send no namespace:tag prefix, or a qas: prefix, not ns:1 as is being created.

                    does anyone know if:

                    a) you can amend the prefixed namespace, currently ns1, to something specific, in this case, qas:
                    b) how you do it! Do I have to send manual headers or something ? any help constructing this would be appreciated.

                    currently, I call this:

                    $response_doAuthenticate = $client->DoSearch($authenticate);
                    

                    and the request is constructed as below:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qas.com/web-2005-10">
                    <SOAP-ENV:Body>
                    <ns1:QASearch>
                    <ns1:Country>GBR</ns1:Country>
                    <ns1:Engine Flatten="true" PromptSet="Default">Authenticate</ns1:Engine>
                    <ns1:Layout>&lt;Default&gt;</ns1:Layout>
                    <ns1:SearchSpec>
                    <ns1:SearchTerm Key="CTRL_SEARCHCONSENT">Yes</ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_TITLE">MR</ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_FORENAME">Zuzu</ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_INITIALS"></ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_SURNAME">Zuzu</ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_DATEOFBIRTH">12/12/1956</ns1:SearchTerm>
                    <ns1:SearchTerm Key="NAME_SEX">M</ns1:SearchTerm>
                    <ns1:SearchTerm Key="ADDR_HOUSENUMBER">27</ns1:SearchTerm>
                    <ns1:SearchTerm Key="ADDR_STREET">Manor Road</ns1:SearchTerm>
                    <ns1:SearchTerm Key="ADDR_DISTRICT">Alresford</ns1:SearchTerm>
                    <ns1:SearchTerm Key="ADDR_TOWN">Zuzuchester</ns1:SearchTerm>
                    <ns1:SearchTerm Key="ADDR_POSTCODE">CO4 4LT</ns1:SearchTerm>
                    </ns1:SearchSpec>
                    </ns1:QASearch>
                    </SOAP-ENV:Body>
                    </SOAP-ENV:Envelope>
                    

                    I need it to to either construct just the following line without the namespace prefix like:

                    <Engine Flatten="true" PromptSet="Default">Authenticate</Engine>
                    

                    or with a specific namespace:

                    <qas:Engine Flatten="true" PromptSet="Default">Authenticate</qas:Engine>
                    

                    or possibly, the whole thing will work

                    <?xml version="1.0" encoding="UTF-8"?>
                    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qas.com/web-2005-10">
                    <SOAP-ENV:Body>
                    <qas:QASearch>
                    <qas:Country>GBR</qas:Country>
                    <qas:Engine Flatten="true" PromptSet="Default">Authenticate</qas:Engine>
                    <qas:Layout>&lt;Default&gt;</qas:Layout>
                    <qas:SearchSpec>
                    <qas:SearchTerm Key="CTRL_SEARCHCONSENT">Yes</qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_TITLE">MR</qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_FORENAME">Zuzu</qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_INITIALS"></qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_SURNAME">Zuzu</qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_DATEOFBIRTH">12/12/1956</qas:SearchTerm>
                    <qas:SearchTerm Key="NAME_SEX">M</qas:SearchTerm>
                    <qas:SearchTerm Key="ADDR_HOUSENUMBER">27</qas:SearchTerm>
                    <qas:SearchTerm Key="ADDR_STREET">Manor Road</qas:SearchTerm>
                    <qas:SearchTerm Key="ADDR_DISTRICT">Alresford</qas:SearchTerm>
                    <qas:SearchTerm Key="ADDR_TOWN">Zuzuchester</qas:SearchTerm>
                    <qas:SearchTerm Key="ADDR_POSTCODE">CO4 4LT</qas:SearchTerm>
                    </qas:SearchSpec>
                    </qas:QASearch>
                    </SOAP-ENV:Body>
                    </SOAP-ENV:Envelope>
                    

                    I'm assuming that I somehow amend the following line, removing the ns1: and changing to qas: to get the prefix

                    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:qas="http://www.qas.com/web-2005-10">
                    

                    Any ideas?

                    Thanks

                      alternatively, can I send a soap Request by constructing the XML myself ? that would be much easier, and put me in control of the namespace.

                      I wish there was a way of just saying namespace = qas: or something.

                        Write a Reply...