JAX-WS SOAP header设值

bp.setOutboundHeader(
  // simple string value as a header, like <simpleHeader>stringValue</simpleHeader>
  Headers.create(new QName("simpleHeader"),"stringValue"),
  // create a header from JAXB object
  Headers.create(jaxbContext,myJaxbObject)
);
MeetingService service = new  MeetingService();
portType = service.getMeetingServiceHttpSoap11Endpoint();

Map<String,Object> reqeustCon=((WSBindingProvider)portType).getRequestContext();
Map<String,List<String>> headers=new HashMap<String,List<String>>();
List<String> l=new ArrayList<String>();
l.add("http://uttest.com/test");
headers.put("TenatInfo", l);
reqeustCon.put(BindingProvider.USERNAME_PROPERTY,"test");
reqeustCon.put(BindingProvider.PASSWORD_PROPERTY,"test");
reqeustCon.put(MessageContext.HTTP_REQUEST_HEADERS,headers);

你可能感兴趣的:(jax-ws)