开发环境:myeclipse8.6+jdk1.6.0_29+tomcat6.0.37

XFire搭建webservice: http://www.cnblogs.com/gavinYang/p/3525339.html

一、搭建WebService

1.新建一个Web Service Project
JAX-WS搭建WebService和客户端访问程序

2.新建一个Java类,写上一个接口方法,一会测试用

package com.ws.test;

public class UserService {

    public String getUserName(String name){
        return name;
    }
    
}

3.New Web Service
JAX-WS搭建WebService和客户端访问程序

4.点击"Next"后,点击Browse找到刚才新建的Java类,选中"Generate WSDL in project"
JAX-WS搭建WebService和客户端访问程序

5.添加JAX-WS类库至项目构建路径
JAX-WS搭建WebService和客户端访问程序

6.部署项目到tomcat,访问url:http://localhost:8080/ws/UserServicePort?wsdl

  <?xml version="1.0" encoding="UTF-8" ?> 
- <!--  Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3-hudson-390-. 
  --> 
- <!--  Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3-hudson-390-. 
  --> 
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.ws.com/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UserServiceService" targetNamespace="http://test.ws.com/">
- <types>
- <xsd:schema>
  <xsd:import namespace="http://test.ws.com/" schemaLocation="http://localhost:8080/ws/UserServicePort?xsd=1" /> 
  </xsd:schema>
  </types>
- <message name="getUserName">
  <part element="tns:getUserName" name="parameters" /> 
  </message>
- <message name="getUserNameResponse">
  <part element="tns:getUserNameResponse" name="parameters" /> 
  </message>
- <portType name="UserServiceDelegate">
- <operation name="getUserName">
  <input message="tns:getUserName" /> 
  <output message="tns:getUserNameResponse" /> 
  </operation>
  </portType>
- <binding name="UserServicePortBinding" type="tns:UserServiceDelegate">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <operation name="getUserName">
  <soap:operation soapAction="" /> 
- <input>
  <soap:body use="literal" /> 
  </input>
- <output>
  <soap:body use="literal" /> 
  </output>
  </operation>
  </binding>
- <service name="UserServiceService">
- <port binding="tns:UserServicePortBinding" name="UserServicePort">
  <soap:address location="http://localhost:8080/ws/UserServicePort" /> 
  </port>
  </service>
  </definitions>
View Code

相关文章:

  • 2021-09-29
  • 2021-04-26
  • 2021-06-06
  • 2021-06-25
  • 2021-12-24
  • 2022-01-10
  • 2022-12-23
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
相关资源
相似解决方案