我是网络服务的新手。我使用ColdFusion 2016并希望拨打此服务网址:https://apitest.authorize.net/xml/v1/request.api。此服务是用C#编写的。如何从ColdFusion中调用用其他语言编写的服务?
还有一件事,我想传递下面的xml数据作为输入。我怎样才能做到这一点?
<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>API LOGIN ID</name>
<transactionKey>TRANSACTION KEY</transactionKey>
</merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>139.94</amount>
<payment>
<creditCard>
<cardNumber>5424000000000015</cardNumber>
<expirationDate>1220</expirationDate>
<cardCode>999</cardCode>
</creditCard>
</payment>
<order>
<invoiceNumber>INV-12345</invoiceNumber>
<description>Golf Supplies</description>
</order>
<lineItems>
<lineItem>
<itemId>243</itemId>
<name>Golf Bag</name>
<description>Blue wheeled golf bag</description>
<quantity>1</quantity>
<unitPrice>129.99</unitPrice>
</lineItem>
<lineItem>
<itemId>42</itemId>
<name>Golf Ball</name>
<description>Long Drive II Balls</description>
<quantity>5</quantity>
<unitPrice>1.99</unitPrice>
</lineItem>
</lineItems>
<customer>
<id>39432</id>
<email>customer@example.com</email>
</customer>
<billTo>
<firstName>John</firstName>
<lastName>Doe</lastName>
<address>1234 Main St</address>
<city>Pecan Springs</city>
<state>TX</state>
<zip>44628</zip>
<country>USA</country>
</billTo>
<shipTo>
<firstName>John</firstName>
<lastName>Doe</lastName>
<address>PO Box 3432</address>
<city>Pecan Springs</city>
<state>TX</state>
<zip>44628</zip>
<country>USA</country>
</shipTo>
</transactionRequest>
</createTransactionRequest>
答案 0 :(得分:0)
我找到了解决方案。
<cfsavecontent variable="strXML">
<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>API LOGIN ID</name>
<transactionKey>TRANSACTION KEY</transactionKey>
</merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>139.94</amount>
<payment>
<creditCard>
<cardNumber>5424000000000015</cardNumber>
<expirationDate>1220</expirationDate>
<cardCode>999</cardCode>
</creditCard>
</payment>
<order>
<invoiceNumber>INV-12345</invoiceNumber>
<description>Golf Supplies</description>
</order>
<lineItems>
<lineItem>
<itemId>243</itemId>
<name>Golf Bag</name>
<description>Blue wheeled golf bag</description>
<quantity>1</quantity>
<unitPrice>129.99</unitPrice>
</lineItem>
<lineItem>
<itemId>42</itemId>
<name>Golf Ball</name>
<description>Long Drive II Balls</description>
<quantity>5</quantity>
<unitPrice>1.99</unitPrice>
</lineItem>
</lineItems>
<customer>
<id>39432</id>
<email>customer@example.com</email>
</customer>
<billTo>
<firstName>John</firstName>
<lastName>Doe</lastName>
<address>1234 Main St</address>
<city>Pecan Springs</city>
<state>TX</state>
<zip>44628</zip>
<country>USA</country>
</billTo>
<shipTo>
<firstName>John</firstName>
<lastName>Doe</lastName>
<address>PO Box 3432</address>
<city>Pecan Springs</city>
<state>TX</state>
<zip>44628</zip>
<country>USA</country>
</shipTo>
</transactionRequest>
</createTransactionRequest>
</cfsavecontent>
<cfhttp
method="post"
url=" https://apitest.authorize.net/xml/v1/request.api"
result="objGet"
>
<cfhttpparam
type="XML"
value="#strXML.Trim()#"
/>
</cfhttp>
<cfdump var="#objGet#"/>