Axis2 Web服务客户端生成 - 无需修改客户端的类型 [英] Axis2 Web Service Client Generation - Types without modifying the client

查看:154
本文介绍了Axis2 Web服务客户端生成 - 无需修改客户端的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Axis2和Eclipse生成Web服务客户端,并让它使用您已在包中创建的java类型,而不是创建自己的类型。原因当然是如果我已经创建了类型A并且它创建了它自己的类型AI不能只将类型A的变量赋值给类型B的变量。

Is it possible with Axis2 and Eclipse to generate a Web Service client and have it use java types that you already have in packages instead of creating it's own types. Reason being of course if I have type A already created and it creates it's own Type A I can't just assign variable of type A to variable of type B.

wsdl正在从部署到应用程序服务器的Web Service生成。
如果无法从中生成它,则可以从已有的java文件生成客户端。

The wsdl is being generated from a Web Service deployed to an application server. If it's not possible to generate it from that would it be possible to generate a client from the already existing java files.

推荐答案

如果您真的想重用现有类,可以直接调用Axis2 API,而无需使用wsdl2java生成客户端。下面是一些调用Web服务的相对简单的代码。您只需要填写Web服务端点,方法QName,预期返回类和服务参数。您可以重用现有的类作为返回值或参数。

If you really want to reuse existing classes, you can call the Axis2 API directly without generating a client using wsdl2java. Below is some relatively simple code to call a web service. You just need to fill in the web service endpoint, method QName, expected return Class(es), and arguments to the service. You could reuse your existing classes as the return values or arguments.

如果您的Web服务非常复杂,那么您可能会发现必须深入了解API才能获得这种工作方式。

If your web service is pretty complicated then you may find that you have to go deeper into the API to get this approach to work.

serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();

EndpointReference targetEPR = new EndpointReference("http://myservice");

options.setTo(targetEPR);

QName methodName = new QName("ns","methodName");

Class<?>[] returnTypes = new Class[] { String.class };

Object[] args = new Object[] { "parameter" };

Object[] response = serviceClient.invokeBlocking(methodName, args,
                returnTypes);

这篇关于Axis2 Web服务客户端生成 - 无需修改客户端的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆