問(wèn)題描述
我需要調(diào)用一個(gè)用 .NET 編寫(xiě)的 Web 服務(wù).發(fā)出調(diào)用的應(yīng)用程序是用 ColdFusion 編寫(xiě)的.Web 服務(wù)需要的參數(shù)之一是 DataSet 對(duì)象.我無(wú)法在 ColdFusion 中實(shí)例化 .NET DataSet 對(duì)象,我怎樣才能向 Web 服務(wù)傳遞它會(huì)接受的東西?我用原始 XML 編寫(xiě) SOAP 請(qǐng)求沒(méi)有問(wèn)題,我只是不知道 DataSet 對(duì)象的 XML 會(huì)是什么樣子.
I need to make a call to a web service written in .NET. The application making the call is written in ColdFusion. One of the parameters the web service expects is a DataSet object. I can't instantiate a .NET DataSet object in ColdFusion, how can I pass the web service something it will accept? I have no problem writing the SOAP request in raw XML, I just don't know what the XML for a DataSet object would look like.
推薦答案
.NET 期望的所有對(duì)象都由 Axis 序列化并且可供您使用.不幸的是,ColdFusion 并不容易獲得.
All objects that .NET expects are serialized by Axis and are available to you. Unfortunately ColdFusion does not make it easy to get to.
要獲取存根,您必須:
- 使用 Coldfusion 以任何方式訪問(wèn) WSDL.
- 在 CF 應(yīng)用目錄中查找存根.他們?cè)谝粋€(gè)潛艇"目錄,由 WSDL.like 組織:c:ColdFusion8stubsWSWS-21028249comfooar
- 將com"中的所有內(nèi)容復(fù)制到存在于CF 類路徑.或者你可以做一個(gè):c:ColdFusion8MyStubscomfooar
- 如果您創(chuàng)建了一個(gè)新目錄,請(qǐng)將其添加到類路徑中.并重啟 CF 服務(wù).
- 像使用任何其他 java 對(duì)象一樣使用它們或 CreateObject()MyObj = CreateObject("java","com.foo.bar.MyObject");
您的數(shù)據(jù)集對(duì)象應(yīng)該以 Axis 決定的任何 java 格式存在.您很可能需要在 cfscript 中完成幾乎所有這些操作
Your dataset object should be in there somewhere in whatever java format Axis decided it should be. Most likely you're going to need to do almost all of this in cfscript
編輯問(wèn)題
SOAP 對(duì)象將定義對(duì)象結(jié)構(gòu),Axis 將創(chuàng)建用于操作它的方法.看一下axis創(chuàng)建的Java對(duì)象.請(qǐng)記住,您可以使用 CFDUMP 查看方法和屬性.
THe SOAP object will define the object structure and Axis will create methods for manipulating it. Take a look at the Java object that axis creates. Remember that you can use CFDUMP to look at the methods and properties.
現(xiàn)在我已經(jīng)看到了 Axis 感到困惑的 .NET 對(duì)象,比如可怕的非泛型集合變成了ArrayOfAnyType".對(duì)于 .NET 開(kāi)發(fā)人員來(lái)說(shuō),在他們的服務(wù)中使用泛型是很重要的,這樣 Axis 才能正確地定義數(shù)組......如果他們不這樣做,那么它很糟糕,你可能無(wú)法在肥皂中使用它.
Now I HAVE seen .NET objects that Axis gets confused by, like the dreaded non-generic collection that turns into a "ArrayOfAnyType". It's important for .NET developers to use Generics in their services so that Axis can define the arrays properly....if they don't then it sucks and you may not be able to work with it in soap.
但是不要害怕obi-won...還有另一種方法.您始終可以以 XML/RPC 類型的樣式與 .NET Web 服務(wù)進(jìn)行交互.這不是自動(dòng)的,它需要大量手動(dòng)解析 XML,這很糟糕,但有時(shí)這是唯一的方法.您應(yīng)該能夠從 .NET 獲得一些幫助,方法是在末尾不帶?wsdl"的情況下找到 .asmx 文件.如果您這樣做,.NET 將生成一堆文檔和示例,說(shuō)明調(diào)用和 XML 的樣子.在這種情況下,您可以只創(chuàng)建 XML 并按照使用 cfhttp 的指定通過(guò)線路傳遞它.祝你好運(yùn)!
but have no fear obi-won...there is another way. You can always interact with .NET web services in a XML/RPC kind of style. It's not automatic, its a lot of hand parsing of XML, it sucks, but sometimes it's the only way to do it. You should be able to get some help from .NET by hitting up the .asmx file without the "?wsdl" on the end. If you do that .NET will generate a bunch of documentation and examples of what the calls and the XML look like. In that case, you can just create the XML and pass it over the wire as specified by using cfhttp. Good Luck!
附:我還應(yīng)該注意,據(jù)我所知,沒(méi)有辦法將手工滾動(dòng)的 XML 與 ColdFusion/Apache Axis 對(duì)象混合,也沒(méi)有辦法為自己的對(duì)象建模以與 CF/Axis 一起使用......你必須使用存根或什么都沒(méi)有
P.S. I should note also that as far as I know there is no way to mix hand rolled XML with the ColdFusion/Apache Axis objects, there is also no way to model your own object for use with CF/Axis...you must use the stubs or nothing
這篇關(guān)于Web 服務(wù)需要一個(gè) DataSet 對(duì)象,我如何通過(guò) ColdFusion 或原始 XML 提供它?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!