private final static String endpoint = "http://172.29.12.125:101/AxionPosService.asmx";

public static void main(String[] args) throws MalformedURLException,

ServiceException, RemoteException {

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(endpoint));

call.setUseSOAPAction(true);

call.setSOAPActionURI("http://AxionPosService.net/QueryResidualAmount");

call.setOperationName(new QName("http://AxionPosService.net/","QueryResidualAmount"));

call.addParameter(new QName("http://AxionPosService.net/","account"), org.apache.axis.encoding.XMLType.XSD_STRING,ParameterMode.IN);

call.addParameter(new QName("http://AxionPosService.net/","orderNo"), org.apache.axis.encoding.XMLType.XSD_STRING,ParameterMode.IN);

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);

//由于需要认证,故需要设置调用的用户名和密码。

SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement("http://AxionPosService.net/", "AuthHeader");

soapHeaderElement.setNamespaceURI("http://AxionPosService.net/");

try{

soapHeaderElement.addChildElement("IdentifyingCode").setValue("12345");

call.addHeader(soapHeaderElement);

}catch (SOAPException e) {

e.printStackTrace();

}

call.addHeader(soapHeaderElement);

String res = (String) call.invoke(new Object[] { "mike.wang", "10" });

}

}

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐