SOAP WebService with Authentication Header: need duplicate auth structure
Hi,
I'm trying to convert some "manual" soap request to the cfinvoke/createObject method, and i find strange to have to do the thing i did ^^
Here is the previous code:
<cfxml variable="LOCAL.SOAP_Request"><cfoutput><?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthenticationHeader xmlns="https://soap.namebay.com/">
<sLogin>#variables.login#</sLogin>
<sPassword>#variables.password#</sPassword>
</AuthenticationHeader>
</soap:Header>
<soap:Body>
<oGetAutoRenew xmlns="https://soap.namebay.com/">
<P_sDomainName>#ndd.domain()#</P_sDomainName>
</oGetAutoRenew>
</soap:Body>
</soap:Envelope></cfoutput></cfxml>
<cfhttp url="https://soap.namebay.com/Domain.asmx?WSDL" method="post">
<cfhttpparam type="header" name="Host" value="soap.namebay.com">
<cfhttpparam type="header" name="Content-Type" value="text/xml;charset=utf-8">
<cfhttpparam type="header" name="Content-Length" value="#len(trim(LOCAL.SOAP_Request))#">
<cfhttpparam type="header" name="SOAPAction" value="https://soap.namebay.com/oGetAutoRenew">
<cfhttpparam type="xml" name="body" value="#trim(LOCAL.SOAP_Request)#">
</cfhttp>
And here is my new code:
<cfset LOCAL.wsNamebay = createObject ( "webservice", "https://soap.namebay.com/Domain.asmx?WSDL" ) />
<cfset LOCAL.doc = XmlNew() />
<cfset LOCAL.doc.AuthenticationHeader = XmlElemNew ( LOCAL.doc, "https://soap.namebay.com/", "AuthenticationHeader" ) />
<cfset LOCAL.doc.AuthenticationHeader.sLogin = XmlElemNew ( LOCAL.doc, "https://soap.namebay.com/", "sLogin" ) />
<cfset LOCAL.doc.AuthenticationHeader.sPassword = XmlElemNew ( LOCAL.doc, "https://soap.namebay.com/", "sPassword" ) />
<cfset LOCAL.doc.AuthenticationHeader.sLogin.XmlText = variables.login />
<cfset LOCAL.doc.AuthenticationHeader.sPassword.XmlText = variables.password />
<cfset addSOAPRequestHeader ( LOCAL.wsNamebay, "ignoredNameSpace", "ignoredName", LOCAL.doc ) />
<!--- FIXME: duplicate, needed don't know why --->
<cfset LOCAL.wsAuth=StructNew() />
<cfset LOCAL.wsAuth["sLogin"]="" />
<cfset LOCAL.wsAuth["sPassword"]="" />
<cfset LOCAL.AutoRenew = wsNamebay.oSetAutoRenew ( LOCAL.ndd.domain(), ARGUMENTS.activate, LOCAL.wsAuth ) />
<cfif LOCAL.AutoRenew.getIReturnCode() eq "200">
<cfreturn true />
<cfelse>
<cfset variables.msg_error = LOCAL.AutoRenew.getSMessage()>
<cfreturn false />
</cfif>
If i remove the LOCAL.wsAuth struct + argument i got the "Web service operation oSetAutoRenew with parameters {domain.com,true} cannot be found." .
If I use an empty struct i got a CF exception with: "Error obtaining parser from data source:AuthenticationHeader cannot be null!"
if i remove the addSOAPRequestHeader line, then i got an webservice error response with "Authentication header cannot be null"
Strangely enough a getSOAPRequest() doesn't show the second arguments structure in any cases ...
Any way to get rid of the LOCAL.wsAuth arg ?
