1
votes

I am trying to use QAS web services for postcode lookup in UK. When I am posting my request XML, it says "Server did not recognize the value of HTTP Header SOAPAction: DoSearch."

When I remove mMethod.setRequestHeader("SOAPAction", "/DoSearch"); from my SOAPClient, the error then received is Unable to handle request without a valid action parameter. Please supply a valid soap action.

The link to WSDL is: https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL

I guess promlem is that I am not being able to set the action parameter in the header, but I dont have any clue on how to do so, and I am kind of stuck. Please help.

The request XML which I am trying to post is:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:qas="http://www.qas.com/OnDemand_2011-03">
<soap:Header>
<qas:QAAuthentication>
<qas:Username>username</qas:Username>
<qas:Password>password</qas:Password>
</qas:QAAuthentication>
</soap:Header>
<soap:Body>
<QASearch RequestTag="Single Line postcode search"
xmlns:web="http://www.qas.com/OnDemand_2011_03">
<web:Country>GBR</web:Country>
<web:Engine Flatten="true ">Singleline</web:Engine>
<web:Layout>QADefault</web:Layout>
<web:Search>B168JR</web:Search>
</QASearch>
</soap:Body>
</soap:Envelope>
1
Can you provide a link to the WSDL ?Michael
I strongly suspect it is because of generated client class files. I would suggest re-generate them again and try.kosa
Try to specify the full action - http://www.qas.com/OnDemand-2011-03/DoSearch.Beau Grantham
Hi @BeauGrantham, I tried specifying full action as well, by doing this: mMethod.setRequestHeader("SOAPAction", "qas.com/OnDemand-2011-03/DoSearch"); but the error remains same. Is there any other way by which I can set this action? I am new to web services and not sure if I am doing it right.Anshul Tiwari

1 Answers

3
votes

Sorry this is so late, I've only just seen your question - I certainly hope you have been able to sort this out before now!

Did you use an automated tool to create that request from the WSDL or create it manually? There are a few problems with the structure of your request that if we change should allow requests.

To get it working you need to be using a structure similar to:

<soap:Envelope
       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:qas="http://www.qas.com/OnDemand-2011-03">
<soap:Header>
<qas:QAQueryHeader>
    <qas:QAAuthentication>
        <qas:Username>username</qas:Username>
        <qas:Password>password</qas:Password>
    </qas:QAAuthentication>
</qas:QAQueryHeader>
</soap:Header>
<soap:Body>
    <qas:QASearch>
        <qas:Country>GBR</qas:Country>
        <qas:Engine Flatten="true ">Singleline</qas:Engine>
        <qas:Layout>QADefault</qas:Layout>
        <qas:Search>B168JR</qas:Search>
    </qas:QASearch>
</soap:Body>
</soap:Envelope>

There are few things I've changed.

  • qas:QAQueryHeader has been added to your header. This is required by the QAS OnDemand service.
  • Corrected your namespace (underscore to dash):
    • Before: xmlns:qas="http://www.qas.com/OnDemand_2011-03"
    • After:xmlns:qas="http://www.qas.com/OnDemand-2011-03"
  • Removed the extra namespace import for QASearch to simplify and tidy the request.