コールドフュージョン アプリケーションから SOAP オーバー HTTP Web サービスを呼び出す必要があります。これには、ユーザーが (多数のフィールドを含む) フォームを送信することが含まれ、コードはこのすべての情報を Web サービスに渡し、応答を取得する必要があります。そのためのプロトタイプに取り組んでいます。
私はこのフォーラムを通過しており、これに関する多くのコード スニペットを見てきましたが、どういうわけかすべてが xml セクションでハードコードされた値を渡しているように見えますが、変数から値を渡す必要があります。変数などを渡そうとすると、コードはそれらを変数としてではなく、テキスト値として扱います。
私のWebサービス呼び出しコードは次のとおりです。
<cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://localhost:8500/Credit Card Soap Web Service"><!---1 this is the cfc location--->
<!---Optional
<soapenv:Header>
<setInit>1</setInit>
<!--- 2 header param --->
</soapenv:Header>--->
<soapenv:Body>
<authorize soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<!---3 cfc method name --->
<name>#elemName.XmlText#</name>
<address>1010 Pine St</address>
<zip>110001</zip>
<state>MO</state>
<country>USA</country>
<cardtype>Visa</cardtype>
<cardnumber>123123123</cardnumber>
<expiry>10-12-2020</expiry>
<amount>50000</amount>
</authorize>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
<cfhttp url="http://localhost:8500/Credit Card Soap Web Service/Credit Card Soap Web Service authorization.cfc" method="post">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="SOAPAction" value="">
<cfhttpparam type="header" name="content-length" value="#len(soap)#">
<cfhttpparam type="header" name="charset" value="utf-8">
<cfhttpparam type="xml" name="message" value="#trim(soap)#">
</cfhttp>
<cfdump var="#xmlparse(cfhttp.FileContent)#">
現時点では、Web サービスは単に渡された値を返しているだけです。まだこの問題を最初に解決しようとしています。
コードに注意してください:
> <name>#elemName.Text#</name>
> <address>1010 Pine St</address>
両方の行は同じように扱われます..実際の値として。XmlText は上記の値として設定されており、これは変数から値を選択しません。
<cfdump var="#xmlparse(cfhttp.FileContent)#">
これは次を出力します:
item XmlText
key XmlText NAME
XmlAttributes struct
xmlns:soapenc http://schemas.xmlsoap.org/soap/encoding/
xsi:type soapenc:string
**value XmlText #elemName.XmlText#**
XmlAttributes struct
xmlns:soapenc http://schemas.xmlsoap.org/soap/encoding/
xsi:type soapenc:string
私がここで間違っていることを教えてください。私は CF に不慣れで、基本を改善しています。
また、エンコーディングスタイルを「ドキュメント」に変更するにはどうすればよいですか
私からさらに情報が必要な場合はお知らせください。
前もって感謝します