【问题标题】:Java webservices - send object in request headersJava webservices - 在请求标头中发送对象
【发布时间】:2016-05-06 01:53:25
【问题描述】:

我正在使用 Jaxws 来使用 Web 服务。在我发送请求时,我需要在请求标头中发送一个对象。当我从 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标头并发送请求。我该怎么做?

这是我的 Soap-ui 请求截图 Please see the SoapUI request format

我的问题是:如何在soap请求头中发送一个java对象。?

提前致谢, 普拉内斯。

【问题讨论】:

    标签: java web-services soap jaxb jax-ws


    【解决方案1】:

    据我了解,您缺少的是 Basic Authentication 标头,您在 HTTP 标头中传递以下内容:

    Authorization: Basic <Base64(username:password)>

    如果请求发送,请检查您的 SOAP-UI。

    以下是一些可以帮助您实现它的 SO 主题:

    1. Java Web Service client basic authentication
    2. How do I consume a web service protected with HTTP basic authentication using the CXF framework?

    【讨论】:

    • No Baderous 它不工作。感谢您的尝试。还在苦苦思索该怎么做。
    猜你喜欢
    • 2015-12-05
    • 1970-01-01
    • 2015-12-27
    • 2012-01-13
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 2018-01-27
    相关资源
    最近更新 更多