此内容没有您所选择的语言版本。

8.2. Generating JAX-WS Client Artifacts


Before we write the regular JAX-WS client we need to generate client artifacts from WSDL. Here's the command to achieve that:
cd $JBOSS_HOME/bin
./wsconsume.sh --keep \          
   --package=org.jboss.test.ws.jaxws.samples.wsrm.generated \
   --output=/home/username/wsrm/cxf/wsconsume/generated/classes \
   --source=/home/username/wsrm/cxf/wsconsume/generated/src \
   /home/username/wsrm/cxf/wsprovide/generated/wsdl/SimpleService.wsdl
Copy to Clipboard Toggle word wrap
The artifacts that have been generated are below.
Compiled classes
Echo.class
ObjectFactory.class
Ping.class
SimpleService_Service.class
EchoResponse.class
package-info.class
SimpleService.class
SimpleService_SimpleServicePort_Client.class
Java sources
Echo.java
ObjectFactory.java
Ping.java
SimpleService_Service.java
EchoResponse.java
package-info.java
SimpleService.java
SimpleService_SimpleServicePort_Client.java
The last step is to write the regular JAX-WS client using generated artifacts.
Writing Regular JAX-WS Client

The following is the regular JAX-WS client using generated artifacts:

package org.jboss.test.ws.jaxws.samples.wsrm.client;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService;

public final class SimpleServiceTestCase
{

   private static final String serviceURL = "http://localhost:8080/jaxws-samples-wsrm/SimpleService";
   
   public static void main(String[] args) throws Exception
   {
      // create service
      QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService");
      URL wsdlURL = new URL(serviceURL + "?wsdl");
      Service service = Service.create(wsdlURL, serviceName);
      SimpleService proxy = (SimpleService)service.getPort(SimpleService.class);
      
      // invoke methods
      proxy.ping(); // one way call
      proxy.echo("Hello World!"); // request responce call
   }
   
}
Copy to Clipboard Toggle word wrap
Now we have both endpoint and client implementations but without WS-Reliable Messaging in place. Our next goal is to turn on the WS-RM feature.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat