I've been on this one a while so any help would be kindly appreciated!!!!
=== QUICK QUESTION ===
How do I write the 2 lines of Java code below in CF to pass into a web service?
---------------
String[] countriesCovered = null;
Attribute[] attributes = null;
-------------
=== LONG QUESTION ===
I'm having problems passing parameters into a web service (WS). Here is the
latest error:
----------
:::Error:::
Unable to create web service argument class [Ljava.lang.String;. Error:
java.lang.InstantiationException: [Ljava.lang.String;. Often this is because
the web service defines an <i>abstract</i> complexType as an input to an
operation. You must create an actual instance of this type in Java.
----------------
:::Here's my code:::
<cfscript>
webservice = CreateObject("webservice","url?wsdl");
countriesCovered.France = JavaCast("string","FR");
result = webservice.doSearch(JavaCast("string","123456"), JavaCast("null",""),
JavaCast("null",""), countriesCovered, JavaCast("null",""));
</cfscript>
----
I've tried so many options (it feels like I can see the top of the hill :)) but
I just can't get doSearch method to work. FYI: I've had no problems getting
strings returned from simple functions (where no input was required) but it's
the complex functions which I can't get to work (like this doSearch method).
Here's some snippets of the WSDL:
------------------
:::Snippet 1:::
<wsdl:types>
<schema targetNamespace="soap.ws.web.raileurope.com">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_xsd_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="Attribute">
<sequence>
<element name="name" nillable="true" type="xsd:string"/>
<element name="value" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="ArrayOfAttribute">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="impl:Attribute[]"/>
</restriction>
</complexContent>
</complexType>
:::: Snippet 2 :::
<wsdl:message name="doSearchResponse">
<wsdl:part name="doSearchReturn" type="impl:SearchResult"/>
</wsdl:message>
<wsdl:message name="doSearchRequest">
<wsdl:part name="key" type="xsd:string"/>
<wsdl:part name="locale" type="xsd:string"/>
<wsdl:part name="style" type="xsd:string"/>
<wsdl:part name="countriesCovered" type="impl:ArrayOf_xsd_string"/>
<wsdl:part name="attributes" type="impl:ArrayOfAttribute"/>
</wsdl:message>
::: Snippet 3 :::
<wsdl:portType name="Test">
<wsdl:operation name="doSearch" parameterOrder="key locale style
countriesCovered attributes">
<wsdl:input message="impl:doSearchRequest" name="doSearchRequest"/>
<wsdl:output message="impl:doSearchResponse" name="doSearchResponse"/>
</wsdl:operation>
::: Snippet 4 :::
<wsdl:binding name="TestWebServiceSoapBinding" type="impl:Test">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="doSearch">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="doSearchRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="soap.ws.web.raileurope.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="doSearchResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="soap.ws.web.raileurope.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
----------------
I asked the programmer who wrote the WS to send some sample code.
:::Here is his Java 5.0 code:::
-------------------------------
String key = null;
String locale = null;
String[] countriesCovered = null;
Attribute[] attributes = null;
key = "123456";
countriesCovered = new String[1];
countriesCovered[0] = "FR";
TestService _service = new TestServiceLocator();
Test _ptr = _service.getRailEuropeWebService();
SearchResult result = _ptr.doSearch(key, locale, null, countriesCovered,
attributes);
-------------------------------
I've thought about writting a wrapper Java class which I could use from my CF
code to call the WS. Is this sensible? My thought was to use the function
supplied above and just add an additional function which I would pass in the
parameters from CF which would then convert all variables to the correct types
and call the WS. I've not actually tested the supplied Java code yet so I'm not
even sure it will work. I was hoping to get it working directly from CF.
I'm off to find a Java book on WS! :) Hope someone can help!
Cheers
Matthew
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244768
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54