简体   繁体   中英

Coldfusion - Creating SOAP Web Service

Here is the XML format that I'm trying to create a web service for:

  <test a1="a1">
     <e1>e1</e1>
     <e2 a2="a2">
        <e3>e3</e3>
        <e3>e3</e3>
     </e2>
  </test>

My problem is that I don't know how to create a Coldfusion (cfcomponent) SOAP web service that would conform to the XML format.

This is what I have come up with:

   <cfcomponent style="document" wsversion = 1 >
        <cffunction name="test" returntype="String" access="remote">
            <cfargument type="String" required="no" name="e1"/>
            <cfargument type="xml" required="no" name="e2" />
            <cfreturn "ok">
        </cffunction>
    </cfcomponent>

As you can see, a1,a2 and e3 are left out as I have no idea how to define them in the cffunction, and I'm not sure if making e2 as xml type is correct.

Any help is appreciated.

you have to use

<cfsavecontent variable="textxml">
 <cfoutput>      
   <test a1="a1">
     <e1>e1</e1>
     <e2 a2="a2">
       <e3>e3</e3>
       <e3>e3</e3>
     </e2>
   </test>
  </cfoutput>
 </cfsavecontent>

and pass the testxml variable to the function as xml type argument.

<cfinvoke method="test" component="compname" xmltest="#textxml#">

no need to send seperate arguments e1 e2...can send testxml variable to the function.

<cfcomponent >
    <cffunction name="test" returntype="String" access="remote">
        <cfargument type="xml" required="no" name="xmltest" />
        <cfset newXML = XMLParse(arguments.xmltest)>
        <cfdump var="#newXML#">
        <cfreturn "ok">
    </cffunction>
</cfcomponent>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM