2

I am using the Experian QAS Pro for Address validation and am having a problem getting my calls to work. I used a SOAP plugin (Chrome Wizdler) and did successfully submit a call, but something in Apex land is making things slightly different when I do the callout from Salesforce, which is resulting in an authentication failure. I used FuseIT SFDC Explorer to import the WSDL, along with some manual tweaks I have documented below. Here is the message that does work, generated by Wizdler:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Header>
        <QAQueryHeader xmlns="http://www.qas.com/OnDemand-2011-03">
            <QAAuthentication>
                <Username>myusername</Username>
                <Password>mypassword</Password>
            </QAAuthentication>
            <Security>
            </Security>
        </QAQueryHeader>
    </Header>
    <Body>
        <QACanSearch xmlns="http://www.qas.com/OnDemand-2011-03">
            <Country>AUS</Country>
            <Engine/>
            <Layout>qaDefault</Layout>
        </QACanSearch>
    </Body>
</Envelope>

And here's the message generated by the Salesforce Apex code that gets an authentication failure. You can see that instead of having the element name "QAQueryHeader", it has "query_header". I guess that's the problem. Just not sure about the fix.

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Header>
        <query_header xmlns="http://www.qas.com/OnDemand-2011-03">
            <QAAuthentication>
                <Username>myusername</Username>
                <Password>mypassword</Password>
            </QAAuthentication>
            <Security/>
        </query_header>
    </env:Header>
    <env:Body>
        <QACanSearch xmlns="http://www.qas.com/OnDemand-2011-03">
            <Country>AUS</Country>
            <Engine/>
            <Layout>QaDefault</Layout>
        </QACanSearch>
    </env:Body>
</env:Envelope>

I made two changes to the code generated from the WSDL. Firstly, I deleted 10 duplicate instances of the following 4 lines inside the subclass wwwQasComOndemand201103.PortType:

private String information_header_hns = 'information_header=http://www.qas.com/OnDemand-2011-03';
public wwwQasComOndemand201103.QAQueryHeader query_header;
private String query_header_hns = 'query_header=http://www.qas.com/OnDemand-2011-03';
public wwwQasComOndemand201103.QAInformation information_header;

Secondly, I changed this declaration inside the wwwQasComOndemand201103.EngineType subclass to be of type String. Given the successful and failing versions of the SOAP message both generate the same empty XML Engine element, I don't think that this is causing a problem.

public wwwQasComOndemand201103.EngineEnumType input;
  • Is this the WSDL? Without some detail of your "manual tweaks" I'm not sure that even someone who knows FuseIT SFDC Explorer well will be able to help you. – Keith C Sep 8 '15 at 7:32
  • @KeithC, thanks for your question. I've only shown the messages generated according to the WSDL I used. The actual WSDL is linked to on this page. I'll look into listing the tweaks tomorrow; think there was only one of consequence, which was to change the type of a variable from an enum to a string to overcome an error. – donmac23 Sep 8 '15 at 11:16
  • Have listed all code changes in the question now. – donmac23 Sep 8 '15 at 22:53
1

To fix the QAQueryHeader you will need to manually adjust the query_header_hns string that is generated.

In public class QAPortType change:

private String query_header_hns = 'query_header=http://www.qas.com/OnDemand-2011-03';

to:

private String query_header_hns = 'QAQueryHeader=http://www.qas.com/OnDemand-2011-03';

Then, when called with this anonymous apex:

wwwQasComOndemand201103.QAPortType service = new wwwQasComOndemand201103.QAPortType();

service.query_header = new wwwQasComOndemand201103.QAQueryHeader();
service.query_header.QAAuthentication = new wwwQasComOndemand201103.QAAuthentication();
service.query_header.QAAuthentication.Username = 'myusername';
service.query_header.QAAuthentication.Password = 'mypassword';

string country = 'AUS';
wwwQasComOndemand201103.EngineType engine = null;
string layout = 'QaDefault';
wwwQasComOndemand201103.QASearchOk_element result = service.DoCanSearch(country,engine,layout);

It produces this CALLOUT_REQUEST:

<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Header>
    <QAQueryHeader xmlns="http://www.qas.com/OnDemand-2011-03">
      <QAAuthentication>
        <Username>myusername</Username>
        <Password>mypassword</Password>
      </QAAuthentication>
      <Security />
    </QAQueryHeader>
  </env:Header>
  <env:Body>
    <QACanSearch xmlns="http://www.qas.com/OnDemand-2011-03">
      <Country>AUS</Country>
      <Engine />
      <Layout>QaDefault</Layout>
    </QACanSearch>
  </env:Body>
</env:Envelope>

I'll have a look through the source for the FuseIT SFDC Explorer to see if I can tidy up some of the generated code for this WSDL.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.