私はColdFusionやXMLの専門家からはほど遠いので、これはおそらくばかげた質問です。しかし、おそらくトランザクション自体にCFMLを含めることによって、SOAPトランザクションの一部を動的に構築する方法はありますか?私が使用しているAPIには、単一のSOAPトランザクション内で多数の単純なクエリを実行できる「MultiQuery」があります。この機能を使用して、前のWebページで提供された一連の一意のIDを使用してクエリを実行したいと思います。「MultiQuery」に追加する必要のあるIDの数が事前にわからないため、「MultiQuery」を含むページの配列に各IDを渡してから、配列をループすることを考えました(「allOfficers」 ")次のようにSOAPトランザクションを構築します。
<cfset queryOpen=HTMLEditFormat("<arr:string>")>
<cfset queryClose=HTMLEditFormat("</arr:string>")>
<soapenv:Body>
<ser:MultiQuery>
<ser:associationGuid>e1c095ca39af</ser:associationGuid>
<ser:queries>
<cfloop index="i" from="1" to="#arrayLen(allOfficers)#">
<cfoutput>#queryOpen#</cfoutput>from Membership memb where memb.Owner='<cfoutput>#allOfficers[1]#</cfoutput>'<cfoutput>#queryClose#</cfoutput>
</cfloop>
</ser:queries>
</ser:MultiQuery>
</soapenv:Body>
もちろん、これは機能しません。配列だけを出力すると、次のような素晴らしい出力が生成されます。
<arr:string>from Membership memb where memb.Owner='006e1c09-25f9-4178-86de-13c3e63200ce'</arr:string>
これは、SOAPエンベロープに必要な形式です。しかし、繰り返しになりますが、これは機能しません。ループからの出力を手動で挿入すると、SOAPトランザクションが正常に機能するため、これは明らかに私が使用しようとしているcfloopです。
ですから、誰かが私にいくつかの提案をしたり、私を正しい方向に向けさせたりすることができれば、私はそれを感謝します。繰り返しになりますが、私は基本的に、SOAPトランザクションに動的に何かを追加しようとしています。よろしくお願いします!
更新:これは、このSOAPリクエストを作成するために使用している完全なコードです。よろしくお願いします!
<cfset queryOpen=HTMLEditFormat("<arr:string>")>
<cfset queryClose=HTMLEditFormat("</arr:string>")>
<cfloop index="i" from="1" to="#arrayLen(allOfficers)#">
<cfoutput>#queryOpen#</cfoutput>from Membership memb where memb.Owner='<cfoutput>#allOfficers[1]#</cfoutput>'<cfoutput>#queryClose#<br /></cfoutput>
</cfloop>
<cfsavecontent variable="soapBody">
<cfoutput>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:imp="http://test.com/Services/Imports" xmlns:ser="http://test.com/Services" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header>
<imp:SessionIdentifier Id="#URL.sessionGuid#"/>
</soapenv:Header>
<soapenv:Body>
<ser:MultiQuery>
<ser:associationGuid>12345</ser:associationGuid>
<ser:queries>
<cfloop index="i" from="1" to="#arrayLen(allOfficers)#">
<cfoutput>#queryOpen#</cfoutput>from Membership memb where memb.Owner='<cfoutput>#allOfficers[i]#</cfoutput>'<cfoutput>#queryClose#</cfoutput>
</cfloop>
</ser:queries>
</ser:MultiQuery>
</soapenv:Body>
</soapenv:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp url="https://test.com/Live/Partner/ObjectService" method="post" useragent="#CGI.http_user_agent#">
<cfhttpparam type="header" name="SOAPAction" value="http://test.com/Services/IObjectService/MultiQuery" />
<cfhttpparam type="header" name="accept-encoding" value="no-compression" />
<cfhttpparam type="xml" name="soapenv" value="#trim(soapBody)#" />
</cfhttp>
<cfset soapBody = xmlParse(cfhttp.fileContent) />
<cfset soapBody = soapBody['s:Envelope']['s:Body'].MultiQueryResponse.MultiQueryResult.Objects.ArrayOfanyType.anyType.Fields />
<cfset keyValue = xmlSearch(soapBody,"//*[local-name()='KeyValueOfstringanyType']") />
次に、keyValue[]をループしてページを作成できます。上記のコードは機能しません。cfloopを取り出して手動で交換すると、動作します。だから私の質問は、SOAP本体のクエリセクションにクエリを追加するにはどうすればよいですか?それとも、それを使用するのに適切なアプローチでさえありますか?各委員会にチャプターオフィサーが何人いるかはわかりません。また、ユーザーがチャプターを選択するまで、そのGUIDもわかりません。
これが理にかなっていることを願っています!助けてくれてありがとう!