Java调用webservice接口测试.doc
文本预览下载声明
Java环境:Eclipse4.4.1 Jdk1.6 Tomcat6 Cxf2.7
1、WebService 服务端文件:
文件组成很简单:webservice接口ICc 和 接口类实现CcImpl
ICc 接口代码如下:
[java] view plaincopyprint?
package com.yp.webservice;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
*
* @author yakcy
* @version v1.0.0
* @date 2014-11-7
*
*/
@WebService(name=ICc,targetNamespace=)
public interface ICc
{
@WebMethod
void showMessages();
}
package com.yp.webservice;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
*
* @author yakcy
* @version v1.0.0
* @date 2014-11-7
*
*/
@WebService(name=ICc,targetNamespace=)
public interface ICc
{
@WebMethod
void showMessages();
}
CcImpl 接口实现代码如下:
[java] view plaincopyprint?
package com.yp.webservice;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
*
* @author yakcy
* @version v1.0.0
* @date 2014-11-7
*
*/
@WebService(name = ICc, targetNamespace = , endpointInterface = com.yp.webservice.ICc)
public class CcImpl implements ICc {
@WebMethod
@Override
public void showMessages() {
System.out.println(Everthing is OK...);
}
}
package com.yp.webservice;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
*
* @author yakcy
* @version v1.0.0
* @date 2014-11-7
*
*/
@WebService(name = ICc, targetNamespace = , endpointInterface = com.yp.webservice.ICc)
public class CcImpl implements ICc {
@WebMethod
@Override
public void showMessages() {
System.out.println(Everthing is OK...);
}
}
2、服务端配置:applicationContext.xml
[html] view plaincopyprint?
?xml version=1.0 encoding=UTF-8?
!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
you under the Apache License, Version 2.0 (the License); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at /licenses
显示全部