daltec
daltec

Reputation: 547

404 Not Found error in SOAP web service request via CFHTTP

I am having a lot of trouble communicating with a web service for our membership database. I get a valid result from my SOAP envelope when using SoapUI. But when I try to send the same envelope using CFHTTP and CF9 (I know, I know), I get a "404 Not Found" error no matter what I try to do. Accessing the URL in a browser gives me an "access denied" error.

Here is what I have in cfsavecontent:

<cfsavecontent variable="soapBody">
    <cfoutput>
    <?xml version=“1.0” encoding=“utf-8”?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://membersuite.com/schemas" xmlns:con="http://membersuite.com/contracts">
       <soapenv:Header>
         <sch:ConciergeRequestHeader>
         <!--Optional:-->
         <sch:BrowserId></sch:BrowserId>
         <!--Optional:-->
         <sch:SessionId></sch:SessionId>
         <sch:AccessKeyId>MyAccessKey</sch:AccessKeyId>
         <!--Optional:-->
         <sch:AssociationId>MyAssociationID</sch:AssociationId>
         <sch:Signature>MySignature</sch:Signature>
         </sch:ConciergeRequestHeader>
       </soapenv:Header>
       <soapenv:Body>
          <con:LoginToPortal>
            <!--Optional:-->
            <con:portalUserName>username</con:portalUserName>
            <!--Optional:-->
            <con:portalPassword>password</con:portalPassword>
          </con:LoginToPortal>
       </soapenv:Body>
    </soapenv:Envelope>
    </cfoutput>
</cfsavecontent>

And here is my cfhttp:

<cfhttp url="https://soap.membersuite.com/mex" method="post" useragent="#CGI.http_user_agent#">
  <cfhttpparam type="header" name="charset" value="utf-8">
  <cfhttpparam type="header" name="mimetype" value="application/xml" /> 
  <cfhttpparam type="header" name="content-type" value="text/xml">
  <cfhttpparam type="header" name="SOAPAction" value="http://membersuite.com/contracts/IConciergeAPIService/LoginToPortal" />
  <cfhttpparam type="header" name="accept-encoding" value="no-compression" />
  <cfhttpparam type="header" name="content-length" value="#len(trim(soapBody))#">
  <cfhttpparam type="xml" name="soapenv" value="#trim(soapBody)#" /> 
</cfhttp>

Dumping cfhttp gives me this error:

enter image description here

It seems obvious to me that the remote server is telling me it cannot find what I am asking it for. But it is the right endpoint, and I can see it in the WSDL:

<wsdl:operation name="LoginToPortal">
    <wsdl:input wsaw:Action="http://membersuite.com/contracts/IConciergeAPIService/LoginToPortal" message="tns:IConciergeAPIService_LoginToPortal_InputMessage"/>
    <wsdl:output wsaw:Action="http://membersuite.com/contracts/IConciergeAPIService/LoginToPortalResponse" message="tns:IConciergeAPIService_LoginToPortal_OutputMessage"/>
</wsdl:operation>

I have also added the SSL cert from the web service page to my CF keystone; no change in error message. I am at my wit's end and would appreciate any suggestions! Again, I am getting expected results back via SoapUI. Thank you all very much!

Upvotes: 1

Views: 13280

Answers (1)

Leigh
Leigh

Reputation: 28873

Going strictly off the SoapUI request, it seems to work if the target URL is changed to https://soap.membersuite.com/. Using bogus credentials, the response changes to "Invalid Access Key ID specified" instead of 404.

<cfhttp url="https://soap.membersuite.com/" method="post" useragent="#CGI.http_user_agent#">
  <cfhttpparam type="header" name="Content-Type" value="text/xml; charset=utf-8" /> 
  <cfhttpparam type="header" name="SOAPAction" value="http://membersuite.com/contracts/IConciergeAPIService/LoginToPortal" />
  <cfhttpparam type="header" name="Accept-Encoding" value="no-compression" />
  <cfhttpparam type="header" name="Content-Length" value="#len(trim(soapBody))#">
  <cfhttpparam type="body" value="#trim(soapBody)#" /> 
</cfhttp>

Upvotes: 1

Related Questions