我必须通过标题发送令牌。这是我正在尝试的代码。
ServiceClient _serviceClient = new ServiceClient();
SOAPHeaderBlock header = new SOAP11HeaderBlockImpl();
header.addAttribute("Content-Type", "text/xml; charset=utf-8", null);
header.addAttribute("LocationToken", "vdsadfafdasfsdas==", null);
header.addAttribute("AccessToken", "zxfadfasfasdfasdfsadf", null);
header.addAttribute("Content-Length", String.valueOf(input), null);
header.addAttribute("SOAPAction","http://example.com/CalculateOrder",null);
_serviceClient.addHeader(header);
owesbservice._setServiceClient(_serviceClient);
我在响应中得到NullpoinException。
CalculateOrderResponseDocument responseDoc = null;
responseDoc = owesbservice.calculateOrder(calculateOrder8);
如何解决这个问题?除此之外,我需要指定POST / GET
答案 0 :(得分:0)
Here is code snipt that send the custom header.
Map<String, String> property = new HashMap<>();
property.put("LocationToken", "vbdffdssgsdf==");
property.put("AccessToken", "fgfsdfsdfddfdfdf==");
options.setProperty( org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS , property);
Before that, I have been sending other information such Content-type to customer header. But If you want to send them, you can use API methods as an example,
options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING ,"UTF-8");
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");