问题描述
我需要调用一个用 .NET 编写的 Web 服务.发出调用的应用程序是用 ColdFusion 编写的.Web 服务需要的参数之一是 DataSet 对象.我无法在 ColdFusion 中实例化 .NET DataSet 对象,我怎样才能向 Web 服务传递它会接受的东西?我用原始 XML 编写 SOAP 请求没有问题,我只是不知道 DataSet 对象的 XML 会是什么样子.
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 期望的所有对象都由 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 以任何方式访问 WSDL.
- 在 CF 应用目录中查找存根.他们在一个潜艇"目录,由 WSDL.like 组织:c:ColdFusion8stubsWSWS-21028249comfooar
- 将com"中的所有内容复制到存在于CF 类路径.或者你可以做一个:c:ColdFusion8MyStubscomfooar
- 如果您创建了一个新目录,请将其添加到类路径中.并重启 CF 服务.
- 像使用任何其他 java 对象一样使用它们或 CreateObject()MyObj = CreateObject("java","com.foo.bar.MyObject");
您的数据集对象应该以 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
编辑问题
SOAP 对象将定义对象结构,Axis 将创建用于操作它的方法.看一下axis创建的Java对象.请记住,您可以使用 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.
现在我已经看到了 Axis 感到困惑的 .NET 对象,比如可怕的非泛型集合变成了ArrayOfAnyType".对于 .NET 开发人员来说,在他们的服务中使用泛型是很重要的,这样 Axis 才能正确地定义数组......如果他们不这样做,那么它很糟糕,你可能无法在肥皂中使用它.
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 服务进行交互.这不是自动的,它需要大量手动解析 XML,这很糟糕,但有时这是唯一的方法.您应该能够从 .NET 获得一些帮助,方法是在末尾不带?wsdl"的情况下找到 .asmx 文件.如果您这样做,.NET 将生成一堆文档和示例,说明调用和 XML 的样子.在这种情况下,您可以只创建 XML 并按照使用 cfhttp 的指定通过线路传递它.祝你好运!
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!
附:我还应该注意,据我所知,没有办法将手工滚动的 XML 与 ColdFusion/Apache Axis 对象混合,也没有办法为自己的对象建模以与 CF/Axis 一起使用......你必须使用存根或什么都没有
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
这篇关于Web 服务需要一个 DataSet 对象,我如何通过 ColdFusion 或原始 XML 提供它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!