soapui的webservice注释问题

时间:2014-09-28 01:23:57

标签: java soapui

我的经理今天给了我一个wsdl网址,他想在我们这边发布一个相同的wsdl,我在将注释请求与spring结合时遇到了问题,有人可以帮忙吗?自定义请求如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:door="http://www.derbysoft.com/doorway">
<soapenv:Header/>
<soapenv:Body>
  <door:PingRequest Token="?" UserName="?" Password="?" Echo="?"/>
</soapenv:Body>
</soapenv:Envelope>

我可以生成如下内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:door="http://www.test.com/doorway">
<soapenv:Header/>
<soapenv:Body>
  <door:PingRequest>
     <PingRequest Echo="?" Token="?" UserName="?" Password="?"/>
  </door:PingRequest>
</soapenv:Body>
</soapenv:Envelope>

它总是包含更多带方法名称的元素,我如何删除它?我在这里附加了我的源代码。

@WebService(name="Example", targetNamespace="http://www.test.com/doorway", serviceName="Example")
@SOAPBinding(style=SOAPBinding.Style.RPC)
@XmlAccessorType(XmlAccessType.NONE)
public class Example {
@WebMethod(operationName="toSayHello",action="sayHello",exclude=false)
public String sayHello(@WebParam(name="userName")String userName) {
    return "Hello:" + userName;
}

@WebMethod()
public void PingRequest(@WebParam(name="PingRequest")PingRequest pingRequest) {
}

}

实体:

@XmlAccessorType(XmlAccessType.NONE)
public class PingRequest
{
@XmlAttribute(name="Echo")
private String echo;
@XmlAttribute(name="Token")
private String token;
@XmlAttribute(name="UserName")
private String userName;
@XmlAttribute(name="Password")
private String password;

public String getToken() {
    return token;
}

public void setToken(String token) {
    this.token = token;
}

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getEcho() {
    return echo;
}

public void setEcho(String echo) {
    this.echo = echo;
}

}

非常感谢提前!!

亲切的问候, 詹姆斯

1 个答案:

答案 0 :(得分:0)

我已经找到了这样做的方法,我们用wsimport工具来做这个,这将生成所有实体类和webservice注释信息,这个案例的注释应该是这样的:@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle。 BARE)