对方给了一个WSDL文件,我生成了JAVA代码,创建了一个测试类。执行报错401.
public class TestApplicatin {
private final static QName serviceName = new QName("xxxx", "MyService");
public static void main(String[] args) throws Exception {
MyService factory = new MyService();
//增加Authorization
URL wsdlUrl = factory.getWSDLDocumentLocation();
Service service = Service.create(wsdlUrl, serviceName);
MyInterface port = service.getPort(MyInterface.class);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
authorizationPolicy.setUserName("username");
authorizationPolicy.setPassword("password");
authorizationPolicy.setAuthorizationType("Basic");
http.setAuthorization(authorizationPolicy);
// 传参
MyInterface myInterface = factory.getHTTPPort();
Bean1 dt = new Bean1();
Bean1.REQUEST s = new REQUEST();
Bean_item1 eq = new Bean_item1();
eq.setREQSYSEVRI("D");
eq.setREQTARSYS("S4DCLNT300");
eq.setREQSRCSYS("HUAXIN");
eq.setREQSENDTIME("20211223151856");
s.baseinfo = eq;
String count = "5";
s.message = new MESSAGE();
s.message.setCOUNT(count);
dt.setREQUEST(s);
//调用接口
Bean2 sp = myInterface.getBean2(dt);
String id = sp.response.baseinforsp.getRSPREQTRACEID();
System.out.println("id:"+id);
}
}
还缺少什么相关代码? 请指导一下