I've been on this one a while so any help would be kindly
appreciated!!!!
=== QUESTION 1 ===
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;
-------------
=== QUESTION 2 ===
I've tried to solve this problem by consuming a simple web
service. If there are any web services experts out there please
show yourself, and show me how to get the code below to work!!!
-----------------------
<cfscript>
ws = CreateObject("webservice","
http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php?wsdl");
NDFDgenResponse =
ws.NDFDgen(JavaCast('double',38.99),JavaCast('double',-77.99),JavaCast('string','time-series'),
DateFormat('2004-01-01','mm/dd/yyyy
hh:ss'),DateFormat('2010-06-26','mm/dd/yyyy hh:ss'));
</cfscript>
<cfdump var="#NDFDgenResponse#">
-----------------------
ANd here's the error:
-------------------
Web service operation "NDFDgen" with parameters
{38.99,-77.99,
time-series,01/01/2004 12:00,06/26/2010 12:00} could not be
found.
-------------------
I'm certain that the problem here is how I'm passing in
parameters.
Weather it be a complex type or a date or whatever, I'm doing
something wrong!
Any ideas... anyone??!?!?!?
=== QUESTION 3 ===
I'm having problems passing parameters into a complex web
service (WS) which I need to consume.
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</icomplexType
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