我已经从 wsdl 文件生成了一些 Java 代码,并且请求本身似乎正在运行,但我无法发送我的凭据。
我已经用一个名为“SoapUI”的工具测试了 Webservice,一切似乎都在运行。
这是(工作)xml 的示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:beac="url">
<soapenv:Header>
<nsAuthn:authnHeader xmlns:nsAuthn="url/auth">
<nsAuthn:id>id</nsAuthn:id>
<nsAuthn:password>password</nsAuthn:password>
</nsAuthn:authnHeader>
</soapenv:Header>
<soapenv:Body>
<beac:getData>
<saisonid>int</saisonid>
</beac:getData>
</soapenv:Body>
</soapenv:Envelope>
这是我的尝试:
public RankDtoResponse getData(int saisonid) throws java.rmi.RemoteException, SOAPException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
SOAPHeaderElement authentication = new SOAPHeaderElement("url","auth");
SOAPHeaderElement user = new SOAPHeaderElement("url","id", "id");
SOAPHeaderElement password = new SOAPHeaderElement("url","password", "password");
try {
authentication.addChild(user);
authentication.addChild(password);
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[3]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("url", "getData"));
setHeader(authentication);
setRequestHeaders(_call);
setAttachments(_call);
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Integer(saisonid)});
大多数代码是由 wsdl2java 从 wsdl 文件自动生成的。
你需要更多信息吗?我错过了什么吗?
提前致谢
阿晨1998
MYYA
相关分类