You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by ESSOUSSI Mohamed Habib <Mo...@telecom-sudparis.eu> on 2012/01/12 17:16:45 UTC
{Disarmed} Re: Unable to send a list from Python to Java under SOAP with SCA
Simo Nash wrote:
> Hi Mohamed,
> Please can you post the generated WSDL file here. Thanks.
>
> Simon
Hello,
Thank you for your help sir.
_*The service interface:*_
package chatserver;
import java.util.List;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface ChatServer {
List<String> checkMessages(int received);
}
_*The wsdl file: *_
<wsdl:definitions name="ChatServerService"
targetNamespace="http://chatserver/" xmlns:tns="http://chatserver/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xs:schema attributeFormDefault="qualified"
elementFormDefault="unqualified" targetNamespace="http://chatserver/"
xmlns:tns="http://chatserver/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element
name="checkMessages"><xs:complexType><xs:sequence><xs:element
minOccurs="0" name="arg0"
type="xs:int"/></xs:sequence></xs:complexType></xs:element><xs:elementname="checkMessagesResponse"><xs:complexType><xs:sequence>*<xs:element
minOccurs="0" name="return" nillable="true"
type="xs:anyType"/>*</xs:sequence></xs:complexType></xs:element></xs:schema>
</wsdl:types>
<wsdl:message name="checkMessages">
<wsdl:part name="checkMessages" element="tns:checkMessages">
</wsdl:part>
</wsdl:message>
<wsdl:message name="checkMessagesResponse">
<wsdl:part name="checkMessagesResponse" element="tns:checkMessagesResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ChatServer">
<wsdl:operation name="checkMessages">
<wsdl:input message="tns:checkMessages">
</wsdl:input>
<wsdl:output message="tns:checkMessagesResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ChatServerBinding" type="tns:ChatServer">
<SOAP:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="checkMessages">
<SOAP:operation/>
<wsdl:input>
<SOAP:body use="literal"/>
</wsdl:input>
<wsdl:output>
<SOAP:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ChatServerService">
<wsdl:port name="ChatServerPort" binding="tns:ChatServerBinding">
<SOAP:address location="http://localhost:9000/server"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
_*My java client:*_
package sca.client;
import java.util.List;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import chatserver.ChatServer;
@Service(Runnable.class)
public class ChatClient implements Runnable {
@Reference
protected ChatServer cs;
@Override
public void run() {
List<String> arr = (List<String>) cs.checkMessages(0);
for (String str : arr) {
System.out.println(arr);
}
}
}
_*The exception:
*_Exception in thread "main" java.lang.ClassCastException:
org.apache.xerces.dom.ElementNSImpl cannot be cast to java.util.List
at sca.client.ChatClient.run(ChatClient.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:156)
at
org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
at
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
at $Proxy32.run(Unknown Source)
at sca.client.launcher.ChatLauncher.main(ChatLauncher.java:17)
--
*ESSOUSSI Mohamed Habib *
TELECOM SudParis
--
Re: {Disarmed} Re: Unable to send a list from Python to Java under SOAP with SCA
Posted by Raymond Feng <en...@gmail.com>.
Using the List<String> as the return type is tricky for SOAP WS as the XML always requires to have a root element. Do you mind trying to create a wrapper JAXB for the List<String>, such as:
public class Messages {
protected List<String> items;
…
// setter and getters
}
Thanks,
Raymond
On Jan 12, 2012, at 8:16 AM, ESSOUSSI Mohamed Habib wrote:
> Simo Nash wrote:
>> Hi Mohamed,
>> Please can you post the generated WSDL file here. Thanks.
>>
>> Simon
> Hello,
>
> Thank you for your help sir.
>
> The service interface:
>
> package chatserver;
>
> import java.util.List;
>
> import org.osoa.sca.annotations.Remotable;
>
> @Remotable
> public interface ChatServer {
> List<String> checkMessages(int received);
> }
>
>
> The wsdl file:
>
> <wsdl:definitions name="ChatServerService" targetNamespace="http://chatserver/" xmlns:tns="http://chatserver/" xmlns:wsdl=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "schemas.xmlsoap.org" "http://schemas.xmlsoap.org/wsdl/" xmlns:xs=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "www.w3.org" "http://www.w3.org/2001/XMLSchema" xmlns:SOAP=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "schemas.xmlsoap.org" "http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP11=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "schemas.xmlsoap.org" "http://schemas.xmlsoap.org/wsdl/soap/">
> <wsdl:types>
> <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://chatserver/" xmlns:tns="http://chatserver/" xmlns:xs=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "www.w3.org" "http://www.w3.org/2001/XMLSchema"><xs:element name="checkMessages"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="arg0" type="xs:int"/></xs:sequence></xs:complexType></xs:element><xs:elementname="checkMessagesResponse"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/></xs:sequence></xs:complexType></xs:element></xs:schema>
> </wsdl:types>
> <wsdl:message name="checkMessages">
> <wsdl:part name="checkMessages" element="tns:checkMessages">
> </wsdl:part>
> </wsdl:message>
> <wsdl:message name="checkMessagesResponse">
> <wsdl:part name="checkMessagesResponse" element="tns:checkMessagesResponse">
> </wsdl:part>
> </wsdl:message>
> <wsdl:portType name="ChatServer">
> <wsdl:operation name="checkMessages">
> <wsdl:input message="tns:checkMessages">
> </wsdl:input>
> <wsdl:output message="tns:checkMessagesResponse">
> </wsdl:output>
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="ChatServerBinding" type="tns:ChatServer">
> <SOAP:binding style="document" transport=MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "schemas.xmlsoap.org" "http://schemas.xmlsoap.org/soap/http"/>
> <wsdl:operation name="checkMessages">
> <SOAP:operation/>
> <wsdl:input>
> <SOAP:body use="literal"/>
> </wsdl:input>
> <wsdl:output>
> <SOAP:body use="literal"/>
> </wsdl:output>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="ChatServerService">
> <wsdl:port name="ChatServerPort" binding="tns:ChatServerBinding">
> <SOAP:address location="http://localhost:9000/server"/>
> </wsdl:port>
> </wsdl:service>
> </wsdl:definitions>
>
> My java client:
>
> package sca.client;
>
> import java.util.List;
>
> import org.osoa.sca.annotations.Reference;
> import org.osoa.sca.annotations.Service;
>
> import chatserver.ChatServer;
>
> @Service(Runnable.class)
> public class ChatClient implements Runnable {
>
> @Reference
> protected ChatServer cs;
>
> @Override
> public void run() {
>
> List<String> arr = (List<String>) cs.checkMessages(0);
> for (String str : arr) {
> System.out.println(arr);
> }
>
> }
>
> }
>
> The exception:
> Exception in thread "main" java.lang.ClassCastException: org.apache.xerces.dom.ElementNSImpl cannot be cast to java.util.List
> at sca.client.ChatClient.run(ChatClient.java:20)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:616)
> at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:156)
> at org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61)
> at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
> at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
> at $Proxy32.run(Unknown Source)
> at sca.client.launcher.ChatLauncher.main(ChatLauncher.java:17)
>
>
>
> --
>
> ESSOUSSI Mohamed Habib
> TELECOM SudParis
> --
>
>