67,512
社区成员
发帖
与我相关
我的任务
分享
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(USER_NAME);
auth.setPassword(USER_PWD);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
[/quote]
应该有影响。
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(USER_NAME);
auth.setPassword(USER_PWD);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(USER_NAME);
auth.setPassword(USER_PWD);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
[/quote]
应该有影响。[/quote]
这种写法是参照官网的API写的,刚刚试了直接写到header里传过去也无效。现在准备用CXF试试。
private static final String url = "接口地址";
private static final String QNAME_URL = "命名空间";
private static final String USER_NAME = "账号";
private static final String USER_PWD = "密码";
public static void ServiceClient(){
try {
ServiceClient client = new ServiceClient();
client.setOptions(buildOptions());
OMElement element = client.sendReceive(buildParam());
Iterator it = element.getChildElements();
while(it.hasNext()){
OMElement omElement = (OMElement) it.next();
System.out.println(omElement.getText());
}
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Options buildOptions(){
Options options = new Options();
options.setTo(new EndpointReference(url));
options.setAction("GetJITOrderList");
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(USER_NAME);
auth.setPassword(USER_PWD);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return options;
}
public static OMElement buildParam(){
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace namespace = factory.createOMNamespace(QNAME_URL, "tns");
OMElement date = factory.createOMElement("MT_JITInfo_Request",namespace);
OMElement input = factory.createOMElement("DATUM",namespace);
input.addChild(factory.createOMText(input, "20130609"));
OMElement input2 = factory.createOMElement("ORDER",namespace);
input2.addChild(factory.createOMText(input2, "X"));
OMElement input3 = factory.createOMElement("MATNR",namespace);
input3.addChild(factory.createOMText(input3, "X"));
OMElement input4 = factory.createOMElement("ZTBBJ",namespace);
input4.addChild(factory.createOMText(input4, "X"));
date.addChild(input);
date.addChild(input2);
date.addChild(input3);
date.addChild(input4);
return date;
}