【问题标题】:How to add headers to SAML/ SOAP request如何向 SAML/SOAP 请求添加标头
【发布时间】:2018-07-25 11:43:42
【问题描述】:

我正在自动化一个肥皂服务,我需要发送带有标头的 SAML 请求。

String endpoint ="https://xyz";
File  xml = new File("path of xml") ;
String req = FileUtils. readFileToString(xml) ;
SOAPConnectionFactory fact = 
SOAPConnectionFactory.newInstance();
SOAPConnection conn = fact.createConnection();
URL end = new URL(endpoint) ;
SOAPMessage Sr = messageFactory.createMesaage(new 
javax.xml.soap.Mineheaders(), New  ByteArrayInputStream(message.getBytes(Charset.forName("UTF-8))));
SOAPMessage soapRes = connection.call(Sr,end);
OutputStream out = new ByteArrayOutputStream() ;
soapRes.writeTo(out);

这是我正在使用的代码。 现在我想设置一些标头我应该如何为请求设置它们? 标题:

POST : afahagajahs 主持人:hsghgfgg Cobtent-type : 文本 内容长度:258 肥皂动作:“”

【问题讨论】:

    标签: java soap header saml


    【解决方案1】:

    您可以使用可以从 SOAPMessage 对象中检索到的 SOAPHeader。请参阅以下 API:

    https://docs.oracle.com/javaee/5/api/javax/xml/soap/SOAPMessage.html https://docs.oracle.com/javaee/5/api/javax/xml/soap/SOAPHeader.html

    【讨论】:

      猜你喜欢
      • 2016-04-10
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多