java响应webservice

webservice调用java的普通接口,要求返回soap报文,该怎么写呢

有帮助的话 采纳一下
webservice调用java普通接口并返回soap响应的方法如下:

  1. 定义一个实现接口的类,在类中调用java普通接口的方法
    public class ServiceImpl implements ServiceInterface {
     public String invokeNormal(String arg) {
         NormalInterface interface = new NormalInterfaceImpl();
         return interface.normalMethod(arg);
     }
    }
    
  2. 将该类发布为webservice,需要加上webservice注解
    @WebService
public class ServiceImpl implements ServiceInterface {
  //...
}
  1. 在该实现类的方法上使用WebMethod和WebResult注解
    @WebMethod
    @WebResult(name="response") 
    public String invokeNormal(String arg) {
    //...
    }
    
  2. 发布这个webservice,比如通过Axis2发布
  3. 调用webservice的客户端会根据WSDL获取soap响应