Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web service is expecting a DataSet object, how can I provide that via ColdFusion or in raw XML?

Tags:

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.

like image 502
Joshua Carmody Avatar asked Nov 18 '09 18:11

Joshua Carmody


1 Answers

All objects that .NET expects are serialized by Axis and are available to you. Unfortunately ColdFusion does not make it easy to get to.

To get to the stubs you must:

  1. Access the WSDL in any way with coldfusion.
  2. Look in the CF app directory for the stubs. They are in a "subs" directory, organized by WSDL.like: c:\ColdFusion8\stubs\WS\WS-21028249\com\foo\bar\
  3. Copy everything from "com" on down into a new directory that exists in the CF class path. or you can make one like: c:\ColdFusion8\MyStubs\com\foo\bar\
  4. If you created a new directory add it to the class path. and restart CF services.
  5. Use them like any other java object with or CreateObject() MyObj = CreateObject("java","com.foo.bar.MyObject");

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


EDIT FOR QUESTIONS

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.

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.

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!

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

like image 93
ryber Avatar answered Oct 12 '22 07:10

ryber