【问题标题】:JAX-WS - where are web service generated classes?JAX-WS - Web 服务生成的类在哪里?
【发布时间】:2011-08-04 09:32:48
【问题描述】:

我正在查看 Java EE 6 教程的第 344 页:

  1. 使用生成的 helloservice.endpoint.HelloService 类,代表 service 在已部署服务的 WSDL 文件的 URI 中: 导入 helloservice.endpoint.HelloService;

这个生成的类在哪里?我包含了应该生成它的服务的 WAR 文件。服务端很好,因为我可以看到 WSDL 生成的模式在 http://localhost:8080/helloservice/HelloService?WSDL

【问题讨论】:

    标签: class service jax-ws generated


    【解决方案1】:

    我查看了我的 java bin 目录并没有找到 wscompile,但我在那里找到了一个 [wsimport][1]。我认为这就是 Java 6 中使用的内容。

    Overview 
    The wsimport tool generates JAX-WS portable artifacts, such as: 
    
    Service Endpoint Interface (SEI)
    Service
    Exception class mapped from wsdl:fault (if any)
    Async Reponse Bean derived from response wsdl:message (if any)
    JAXB generated value types (mapped java classes from schema types)
    These artifacts can be packaged in a WAR file with the WSDL and schema documents along with the endpoint implementation to be deployed. also provides wsimport ant task, see Wsimport ant task. 
    
    
    Launching wsimport 
    Solaris/Linux 
    /bin/wsimport.sh -help
    Windows 
    \bin\wsimport.bat -help
    

    【讨论】:

      【解决方案2】:

      这是来自 oracle 的 javaee tutorial 的链接:

      generate-wsdl 任务 generate-wsdl 任务运行 wscompile,它创建 WSDL 和映射文件。 WSDL 文件描述 Web 服务并用于在静态存根客户端中生成客户端存根。映射文件包含与 Java 接口和 WSDL 定义之间的映射相关的信息。它具有可移植性,因此任何符合 J2EE 的部署工具都可以使用此信息以及 WSDL 文件和 Java 接口来为已部署的 Web 服务生成存根和关联。

      The files created in this example are MyHelloService.wsdl and mapping.xml. The generate-wsdl task runs wscompile with the following arguments: 
      
      wscompile -define -mapping build/mapping.xml -d build -nd build 
      -classpath build config-interface.xml 
      The -classpath flag instructs wscompile to read the SEI in the build directory, and the -define flag instructs wscompile to create WSDL and mapping files. The -mapping flag specifies the mapping file name. The -d and -nd flags tell the tool to write class and WSDL files to the build subdirectory. 
      
      The wscompile tool reads an interface configuration file that specifies information about the SEI. In this example, the configuration file is named config-interface.xml and contains the following: 
      
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration 
        xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
        <service 
            name="MyHelloService" 
            targetNamespace="urn:Foo" 
            typeNamespace="urn:Foo" 
            packageName="helloservice">
            <interface name="helloservice.HelloIF"/>
        </service>
      </configuration> 
      This configuration file tells wscompile to create a WSDL file named MyHello
      Service.wsdl with the following information: 
      
      •The service name is MyHelloService.
      •The WSDL target and type namespace is urn:Foo. The choice for what to use for the namespaces is up to you. The role of the namespaces is similar to the use of Java package names--to distinguish names that might otherwise conflict. For example, a company can decide that all its Java code should be in the package com.wombat.*. Similarly, it can also decide to use the namespace http://wombat.com. 
      •The SEI is helloservice.HelloIF.
      The packageName attribute instructs wscompile to put the service classes into the helloservice package. 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-05
        • 1970-01-01
        • 2012-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-16
        • 2023-03-07
        相关资源
        最近更新 更多