Reputation: 1792
I'm looking to consume a SOAP web service which requires an object to be passed as a parameter e.g.
<cfset someVariable = createObject("webservice", "http://www.example.com/webservice")>
Which has a method
someMethod(org.example.schemas._2004._07.example_api_objects.Example)
Example
is a complex object with a number of properties, methods etc. I can access the relevent stub file relating to Example
in ColdFusion10\cfusion\stubs\WS403970439_1\org\example\schemas._2004._07.example_api_objects
and have found that if this is added to the class path I can use the following:
<cfset someExample = CreateObject("java", "org.example.schemas._2004._07.example_api_objects.Exampler").init()>
<cfset someVariable.someMethod(someExample)>
I'm sure I should be able to create the someExample object directly through ColdFusion without needing to add the relevant stub files to the classpath, but I haven't been able to do this - does anyone know how this might be possible?
Upvotes: 4
Views: 495
Reputation: 123
<cfset someExample = someVariable.getClass().getClassLoader().loadClass('org.example.schemas._2004._07.example_api_objects.Example').newInstance() />
Then just use the setters and getters on the someExample object to set your values...
Doing it the other way is not robust enough. What if the wsdl changes?
Upvotes: 1