我正在使用 Jaxws 来使用 Web 服务。当我发送请求时,我需要在请求 header 中发送一个对象。当我从 Soap-UI 调用服务时,我成功获取了数据。但在java中也是一样,我无法得到它。我对此进行了很多研究,任何人都知道请帮助我如何做到这一点。
这是我的java代码
//getting the service
MyService servc = new MyService();
MyServiceSoap soap = servc.getMyServiceSoap();
//call the service
System.out.println(soap.SERVICE_A("123456789")); //getting null as response because i am not setting userid, password
我想将用户 ID、密码设置为 Authentication pojo 对象,并将其设置为 SOAP header 并发送请求。我怎样才能做到这一点。?
这是我的 Soap-ui 请求屏幕截图 Please see the SoapUI request format
我的问题是:如何在soap请求 header 中发送java对象?
提前致谢, 普拉尼斯。
最佳答案
据我了解,您缺少的是 Basic Authentication headers,您可以在 HTTP header 中传递以下内容:
Authorization: Basic <Base64(username:password)>
检查您的 SOAP-UI 是否发送此请求。
以下是一些可以帮助您实现它的主题:
关于Java webservices - 在请求 header 中发送对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35065725/