我用cxf实现做的webservices,接口如下;
- Java code
import javax.jws.WebParam;import javax.jws.WebService;@WebService(name = "IReportNames", targetNamespace = "http://reportNames.fi/")public interface IReportNames { public String getReportNames(@WebParam(name="AuthenticationToken",targetNamespace = "aaa",header=true) Authentication auth,@WebParam(name="dataType") String type);}
发送到服务器端的信息样式是下面这样:
- XML code
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> [color=#0000FF]<ns2:Authentication xmlns:ns2="http://header.webservice.main.fi/">[/color] <appKey>your appKey</appKey> <appSecret>your appSecret</appSecret> </ns2:Authentication> </soap:Header> <soap:Body> <getReportNames> <dataType>json</dataType> </getReportNames> </soap:Body> </soap:Envelope>
而服务器端要求的接收到的信息样式是这样的:
- XML code
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <AuthenticationToken> <appKey>your appKey</appKey> <appSecret>your appSecret</appSecret> </AuthenticationToken> </soap:Header> <soap:Body> <getReportNames> <dataType>json</dataType> </getReportNames> </soap:Body> </soap:Envelope>
这样服务器就不认识我发送的信息,有没有什么方法可以把<ns2:Authentication xmlns:ns2="http://header.webservice.main.fi/">这里面多余的东西给去掉。
------解决方案--------------------
是不是AuthenticationToken 这个类,而不是这个 Authentication