客户端编程t调用Webservice

package com.cgm.clientservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_02-b08-fcs
* Generated source version: 2.0
*
*/
@WebService(name = "WS_01", targetNamespace = "http://ws.cgm.com/")
public interface WS01 {


/**
*
* @param arg0
* @return
* returns java.lang.String
*/
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "sayHello", targetNamespace = "http://ws.cgm.com/", className = "com.cgm.ws.SayHello")
@ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://ws.cgm.com/", className = "com.cgm.ws.SayHelloResponse")
public String sayHello(
@WebParam(name = "arg0", targetNamespace = "")
String arg0);

}


package com.cgm.clientservice;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;


/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_02-b08-fcs
* Generated source version: 2.0
*
*/
@WebServiceClient(name = "WS_01Service", targetNamespace = "http://ws.cgm.com/", wsdlLocation = "http://192.168.111.100:6789/hello?wsdl")
public class WS01Service
extends Service
{

private final static URL WS01SERVICE_WSDL_LOCATION;

static {
URL url = null;
try {
url = new URL("http://192.168.111.100:6789/hello?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
WS01SERVICE_WSDL_LOCATION = url;
}

public WS01Service(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}

public WS01Service() {
super(WS01SERVICE_WSDL_LOCATION, new QName("http://ws.cgm.com/", "WS_01Service"));
}

/**
*
* @return
* returns WS01
*/
@WebEndpoint(name = "WS_01Port")
public WS01 getWS01Port() {
return (WS01)super.getPort(new QName("http://ws.cgm.com/", "WS_01Port"), WS01.class);
}

}


package com.cgm.clientservice;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;


public class APP {

public static void main(String[] args) {

try {
URL ws=new URL("http://192.168.111.101:6789/hello?wsdl");
Service s= Service.create( ws, new QName("http://ws.cgm.com/","WS_01Service"));
WS01 hs= (WS01) s.getPort(new QName("http://ws.cgm.com/","WS_01Port"), WS01.class);
String ss=hs.sayHello("ssssss");
System.out.println(ss);
} catch (Exception e) {
e.printStackTrace();
}


}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值