1

ColdFusion8を使用してasp.netWebサービスを利用し、XMLファイルを返す必要があります。

asp.netサービスと通信できますが、渡した情報が無効であるという基本的なエラーがサービスから返されます。

これが私のコードの要約です:

<cfxml variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"   
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Body>
<cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>  
  <strApplicationKey>myappkey</strApplicationKey>
  <UID>myuserid</UID>
  <arrProperties>
    <Property>
      <Name>IP</Name>
      <Value>127.0.0.1</Value>
    </Property>
  </arrProperties>
  <arrRoles />
</GetSession>
</soap:Body>
</soap:Envelope>         
</cfxml>

<cfhttp url="#apiurl#" method="post" result="httpresponse" port="443">

  <cfhttpparam type="header" name="content-type" value="text/xml"> 
  <cfhttpparam type="header" name="SOAPAction" value="#mysoapaction#"> 
  <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#"> 
  <cfhttpparam type="header" name="charset" value="utf-8">
  <cfhttpparam type="Body" value="#trim(soap)#" name="FileContent"/>  

</cfhttp>

<cfdump var="#GetHttpRequestData()#" label="Get Http Request Data" />

送信されている情報をプレビューして、ColdFusionが実際にXML / SOAPリクエストを送信していることを確認する方法はありますか?

私は#GetHttpRequestData()#いくつかのデータを返すために使用しましたが、構造内ではコンテンツは「空の文字列」であり、これは私が助けを必要としているところです。これは空にする必要がありますか?これは私にとっては新しいことですが、asp.netサービスに渡される私の情報がそこにあると思っていたと思います。

参考までに-HTTPとSOAPの応答は問題なく表示されますが、リクエスト情報は表示されません。リクエスト情報を表示するにはどうすればよいですか?

問題が私の側にあるのか、それとも彼らの側にあるのかを判断しようとしていて、この時点で事実を収集する必要があります。

4

3 に答える 3

2

Webサービスを操作する際のもう1つの貴重なツールは、soapUIです。それは間違いなくあなたのツールキットの一部であるべきです。soapUIを使用してリクエストを作成し、応答を確認できます。soapUIを使用できるようになったら、リクエストをColdFusionコードにコピーできます。

私が気づいたことの1つは、XMLをcfxmlタグでラップしていることです。それがあなたの要求を台無しにしているかどうかはわかりません。私は通常、XMLリクエストをcfsavecontentタグでラップします。したがって、次のようにコードを変更してみることができます。

<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
   <cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>  
   <strApplicationKey>myappkey</strApplicationKey>
   <UID>myuserid</UID>
   <arrProperties>
     <Property>
       <Name>IP</Name>
       <Value>127.0.0.1</Value>
     </Property>
   </arrProperties>
   <arrRoles />
   </GetSession>
   </soap:Body>
</soap:Envelope>         
</cfsavecontent>

残りのコードは同じままにすることができます。

于 2012-09-14T13:07:14.623 に答える
1

If you're on Windows (or have a windows machine to hand) install Fiddler and start it. It's a proxy that listens on port 8888 by default so in your cfhttp call, add proxyServer="127.0.0.1" and proxyPort="8888" and run your request again.

Just noticed that you're using port 443, so probably SSL. You can enable HTTPS decrypt Tools->Fiddler Options->HTTPS Tab->Decrypt HTTPS traffic. You may then also need to import the Certificate that Fiddler uses into your keystore.

Each request will now show up in Fiddler and you can use the request and response inspectors on the right to look at the exact data going between the servers (the Raw tab shows the data unchanged). This has saved me so many times and is now part of my standard toolkit.

In your particular case, is there a reason you're not using CreateObject("webservice","http://....") . I'm assuming that it's not playing well with a .Net-based webservice?

Also, the call to GetHttpRequestData() shows the request you made to your test page, not the HTTP call you made to the test webservice. Unfortunately, CFHTTP doesn't return any structure showing the full HTTP request details it used. I think that would be a pretty sound feature request, as at the moment, you'll have to use a tool like fiddler or wireshark to see what was sent.

于 2012-09-14T08:30:54.400 に答える
0

ドットネットの単純な問題は、ColdFusionによって作成されたXMLドキュメントを処理できないことです。XMLをドットネットに戻すには、文字列形式(XMLvariable.Tostring)に変換します

HTTPリクエストのパラメータは
<cfhttpparam type="Body" value="#trim(soap).ToString#" name="FileContent"/>

于 2014-07-25T11:04:30.803 に答える