Using Worklight 6.2.0.0.
I'm trying to consume one of our corporate web services via Worklight's HTTP Adapter. I have the WSDL for the web service, and I used the "Discover Backend Services" tool to generate the adapter JavaScript and XML.
The web service has 2 input parameters and 3 output parameters, all strings.
When I come to invoke the procedure on the client, I'm doing this:
var invocationData = {
adapter : 'messageHandlerAdapter',
procedure : 'messageHandlerService_messageHandler',
parameters : ['a','b']
};
var invocationOptions = {
onSuccess : messageHandlerSuccess,
onFailure : messageHandlerFailure
};
WL.Client.invokeProcedure(invocationData,invocationOptions);
You can see the dummy parameters in the invocationData array. Running this results in the following error:
java.lang.String cannot be cast to org.mozilla.javascript.Scriptable
If I remove the parameters, I don't get an error and the web service call appears to be successful, but I don't get any response (obviously).
A search on the forums led me to this:
http://stackoverflow.com/questions/23192346/class-cast-java-lang-string-cannot-be-cast-to-org-mozilla-javascript-scriptable Which is along the same lines, and the response was that there might be an invalid JSON object somewhere. However, all I've done is used the auto-generated adapter code and called it.
I'm very new to Worklight, so any advice is gratefully received!
WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="messageHandler" targetNamespace="urn:messageHandler" xmlns:tns="urn:messageHandler" xmlns:S2="urn:messageHandler:messageHandler" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:S1="urn:soap-fault:details" xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation>EncodingType=DOC_LITERAL, WSA_Product=10.1A - N/A</wsdl:documentation>
<wsdl:types>
<schema elementFormDefault="unqualified" targetNamespace="urn:soap-fault:details" xmlns="http://www.w3.org/2001/XMLSchema"><element name="FaultDetail"><complexType><sequence><element name="errorMessage" type="xsd:string"/><element name="requestID" type="xsd:string"/></sequence></complexType></element></schema>
<schema elementFormDefault="qualified" targetNamespace="urn:messageHandler:messageHandler" xmlns="http://www.w3.org/2001/XMLSchema"><element name="messageHandler"><complexType><sequence><element name="ipMessageParams" nillable="true" type="xsd:string"/><element name="ipMessageData" nillable="true" type="xsd:string"/></sequence></complexType></element><element name="messageHandlerResponse"><complexType><sequence><element name="result" nillable="true" type="xsd:string"/><element name="opMessageResponse" nillable="true" type="xsd:string"/><element name="opMessageData" nillable="true" type="xsd:string"/></sequence></complexType></element></schema>
</wsdl:types>
<wsdl:message name="messageHandler_messageHandlerResponse">
<wsdl:part name="parameters" element="S2:messageHandlerResponse"/>
</wsdl:message>
<wsdl:message name="FaultDetailMessage">
<wsdl:part name="FaultDetail" element="S1:FaultDetail"/>
</wsdl:message>
<wsdl:message name="messageHandler_messageHandler">
<wsdl:part name="parameters" element="S2:messageHandler"/>
</wsdl:message>
<wsdl:portType name="messageHandlerObj">
<wsdl:operation name="messageHandler">
<wsdl:input message="tns:messageHandler_messageHandler"/>
<wsdl:output message="tns:messageHandler_messageHandlerResponse"/>
<wsdl:fault name="messageHandlerFault" message="tns:FaultDetailMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="messageHandlerObj" type="tns:messageHandlerObj">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="messageHandler">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="messageHandlerFault">
<soap:fault name="messageHandlerFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="messageHandlerService">
<wsdl:port name="messageHandlerObj" binding="tns:messageHandlerObj">
<documentation></documentation>
<soap:address location="redacted"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Here is a link to a pic of the Service description in Project Explorer.