为什么Java Client在运行时需要WSDL? [英] Why is WSDL required for Java Client at runtime?

查看:136
本文介绍了为什么Java Client在运行时需要WSDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为Java WS客户端生成工件后,

After generating the artifacts for a Java WS client,


  • 为什么需要wsdllocation引用?

  • 为什么运行时需要WSDL?

我可能会看到一些验证的原因,但不应该是可选的?

I might see a reason for some validation, but shouldn't that be optional?

推荐答案

总结:从设计的角度来看,Web服务客户端不需要WSDL,实现由Sun实现的Web服务客户端对WSDL的依赖性很强。显而易见的目的是动态生成一些运行时依赖项。

Summary: While from a design perspective the WSDL is not necessary for a web service client, the implementation effected by Sun for a web service client has a hard dependency on the WSDL. The apparent purpose is to generate some of the runtime dependencies dynamically.

首先:打包你的是一个好习惯WSDL,并引用它,如果您希望生成可移植客户端。

First: it is considered a good practice to package your WSDL, and reference it, if you expect to produce a portable client.

现在,除此之外,如果实现生成所有必需的运行时工件,则不需要WSDL 。

Now, with that aside, the WSDL would not be required if the implementation generated all required runtime artifacts.

对于Java,wsimport工具会生成一些静态工件(接口和可能支持代码以满足性能目标),并使其他元素在运行时动态创建。从一开始,我们就看到WSDL文档在Service构造函数中占主要位置:

For Java, the wsimport tool generates some static artifacts (interfaces and possibly support code to meet performance targets) and leaves other elements to be dynamically created at runtime. From the start, we see the WSDL document takes a primary position in the Service constructor:

protected Service(java.net.URL wsdlDocumentLocation, QName serviceName)
    delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation,
                                                         serviceName,
                                                         this.getClass());
}

WSDL文档被解析为数据流;如果没有提供,它默认为(自由提取核心本质):

The WSDL document is resolved to a source data stream; if not provided, it defaults to (liberties taken to extract the core essence):


source = new StreamSource(... webserviceclient.wsdlLocation ()...);

source = new StreamSource( ... webserviceclient.wsdlLocation() ... );

并深入挖掘WSServiceDelegate:

and digging deeper, to a WSServiceDelegate:

WSDLModelImpl wsdlmodelimpl = parseWSDL(url, source);
wsdlserviceimpl = wsdlmodelimpl.getService(serviceName);

它正在动态创建至少部分基础服务支持。

It's creating at least some portion of the underlying service support dynamically.

wsdlLocation是Java实现的组成部分。

The wsdlLocation is integral to the Java implementation.

这篇关于为什么Java Client在运行时需要WSDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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