Need suggestion on one small thing about soap web service in cf -


Please suggest to me what is the correct way to get method arguments with SAP in CF web service

< P> Below is my sample code for web service method, where i & lt; cfargument > but parsing xml request

  & lt; Cffunction name = "method1" displayname = "method name" description = "method description" access = "remote" output = "true" returntype = "xml" & gt; & Lt; Cfset is SOAP = isSOAPRequest () & gt; & Lt; Cfif is SOAP & gt; Get the first header as a string & lt; Cfset reqxml = GetSOAPRequest () & gt; & Lt; Cfset reqxml1 = XmlParse (reqxml) & gt; & Lt; Cfset responseNodes = xml search (# reqxml1 #, "soapnavi: envelope / soap: body") /> & Lt; Cfset responseNodes = xmlparse (response node [1]) /> & Lt; Cfif structKeyExists (responseNodes.xmlroot, "AgentID") & gt; & Lt; CFSET AgentID = trim (responseNodes.xmlroot.AgentID.xmltext) & gt; & Lt; Cfelse & gt; & Lt; Cfset process = 0 & gt; & Lt; Cfset responce ['errorcode'] = "mg1000" & gt; & Lt; Cfset responce ['error message'] = "agent id not found in request" & gt; & Lt; Cfset AnythingToXML = createObject ('element', 'AnythingToXML.AnythingToXML'). Init () /> & Lt; Cfset myXML = AnythingToXML.toXML (responce, "StatusResponse") /> & Lt; Cfset result = xmlparse (myXML) & gt; & Lt; Cfreturn result & gt; & Lt; / Cfif>  

But I think I should replace the xml request instead of parsing & lt; Must use cfargument > Please tell what is the correct way to do this.

Your cold fusion SOAP method can be as simple as possible, Like:

  & lt; Cffunction name = "yourMethod" access = "remote" output = "false" returntype = "struct" & gt; & Lt; Cfargument name = "testString" type = "string" & gt; & Lt; Cfset local.out = structNew () & gt; & Lt; Cfset local.out.argIn = arguments.testString & gt; & Lt; Cfset local.out.additionalValue = "Hello World" & gt; & Lt; Cfreturn local.out & gt; & Lt; / Cffunction & gt;  

ColdFusion will allow remote function access through SOAP requests, such as isSOAPRequest () and GetSOAPRequest () There is no need to rely on it unless you are doing more complex work, like data in SOAP headers is required. Do you add SOAP wsdl to your component name? Wsdl can see, such as localhost \ yourservice.cfc? Wsdl

You can return any data type that ColdFusion can serialize. In my example I opted to return a structure, which would return a map in SOAP.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -