java soap 头_如何将java头添加到java中的soaprequest
如果要將HTTP標(biāo)頭添加到SOAP請求或響應(yīng)中,則無關(guān)緊要。您應(yīng)該使用MessageContext的方式。
假設(shè)msgContext是您的Axis2請求/響應(yīng)消息上下文對象(org.apache.axis2.context.MessageContext),下面的代碼將執(zhí)行操作并使用它,您可以添加HTTP標(biāo)頭。
`//Instantiate an Options object from org.apache.axis2.client.Options
Options options = new Options();
//Instantiate an ArrayList of type NamedValue from org.apache.axis2.context.NamedValue
List namedValuePairs = new ArrayList();
//Add as much as headers you want using below code
namedValuePairs.add(new NamedValue("sample", "value"));
//Finally add namedValuePairs to options, and add options to msgContext
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, namedValuePairs);
msgContext.setOptions(options);`
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的java soap 头_如何将java头添加到java中的soaprequest的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 缤越汽车怎么样 详解缤越汽车的性能和口碑
- 下一篇: java编写代码时易出错_JAVA中易出