0

我是网络服务的新手。我正在使用 ColdFusion 2016 并想调用此服务 url: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>
4

1 回答 1

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#"/>
于 2017-12-20T12:37:28.890 回答