users@glassfish.java.net

Re: Calling a Web Service making use of DII

From: Lukas Jungmann <Lukas.Jungmann_at_Sun.COM>
Date: Sat, 03 Mar 2007 02:45:11 +0100

Hi,

glassfish_at_javadesktop.org wrote:
> Hello,
>
> I would like to know if there is a way to call a Web Service making use of Dynamic Invocation Interface and JEE 5 api, only using wsdl file without generating proxy classes with wsimport.

check Service.createDispatch[1] and related samples[2]

--lj

[1]:
https://jax-ws.dev.java.net/nonav/jax-ws-20-fcs/api/javax/xml/ws/Service.html#createDispatch(javax.xml.namespace.QName,%20java.lang.Class,%20javax.xml.ws.Service.Mode)
[2]: https://jax-ws.dev.java.net/nonav/2.1/docs/samples.html

> The code should be similar to the following examples (it doesn't work because I have the following exception:
>
> operation style: "rpc" not supported
> at com.sun.xml.rpc.client.dii.BasicCall.unsupportedOperationStyleException(BasicCall.java:566)
> at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:498)
> )
>
> public class Main {
>
> private static String qnameService = "TestService";
> private static String qnamePort = "TestPort";
>
> private static String BODY_NAMESPACE_VALUE = "http://org.irriis.mit";
> private static String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
> private static String NS_XSD = "http://www.w3.org/2001/XMLSchema";
> private static String URI_ENCODING = "http://schemas.xmlsoap.org/soap/http";
>
>
>
> /** Creates a new instance of Main */
> public Main() {
> try {
> ServiceFactory factory = ServiceFactory.newInstance();
> Service service = factory.createService(new QName(qnameService));
> QName port = new QName(qnamePort);
> Call call = service.createCall(port);
> call.setTargetEndpointAddress("http://erg4082:8080/JBossWsServer/TestSession?wsdl");
> call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
> call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
> call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
> QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
> call.setReturnType(QNAME_TYPE_STRING);
> call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "saluto"));
> call.addParameter("String_1", QNAME_TYPE_STRING, ParameterMode.IN);
> String[] params = { "Murph!" };
> String result = (String)call.invoke(params);
> System.out.println(result);
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> }
> [Message sent by forum member 'giordano48' (giordano48)]
>
> http://forums.java.net/jive/thread.jspa?messageID=205208
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>