cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrei Shakirin <ashaki...@talend.com>
Subject RE: Insert elements in soap header?
Date Wed, 20 Feb 2013 08:40:57 GMT
Hi,

Basically you can add any custom soap header on client side using this code:

Client proxy = ClientProxy.getClient(serviceClient);
List<Header> headersList = new ArrayList<Header>();
Header testSoapHeader1 = new Header(new QName("uri:singz.ws.sample", "soapheader1"), "SOAP
Header Message 1", new JAXBDataBinding(String.class));
Header testSoapHeader2 = new Header(new QName("uri:singz.ws.sample", "soapheader2"), "SOAP
Header Message 2", new JAXBDataBinding(String.class));
headersList.add(testSoapHeader1);
headersList.add(testSoapHeader2);
proxy.getRequestContext().put(Header.HEADER_LIST, headersList);

Or in interceptor:
 public void setSoapHeaderValue(SoapMessage soapMessage, QName name, String value) {
                List<Header> headers = soapMessage.getHeaders();
                Header testSoapHeader = new Header(new QName("uri:singz.ws.sample", "soapheader1"),
"SOAP Header Message 1", new JAXBDataBinding(String.class));	headers.add(testSoapHeader);
}

Anyway to set WS-Addressing header I would recommend to use standard CXF feature or WS-policy:
http://cxf.apache.org/docs/ws-addressing.html

Regards,
Andrei.


> -----Original Message-----
> From: meteora28 [mailto:s.r.s@web.de]
> Sent: Dienstag, 19. Februar 2013 16:21
> To: users@cxf.apache.org
> Subject: Re: Insert elements in soap header?
> 
> Thank you for your answers, but I could not solve it yet.
> 
> Currently I have this message:
> 
> POST /onvif/services HTTP/1.1
> Content-Type: application/soap+xml;
> action="http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/Pull
> MessagesRequest";
> charset=UTF-8
> Accept: */*
> User-Agent: Apache CXF 2.7.2
> Cache-Control: no-cache
> Pragma: no-cache
> Host: 172.16.101.130
> Connection: keep-alive
> Content-Length: 1463
> 
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-
> envelope">
> 	<soap:Header>
> 		<wsse:Security
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-utility-1.0.xsd"
> soap:mustUnderstand="true">
> 			<wsse:UsernameToken wsu:Id="UsernameToken-
> 14">
> 				<wsse:Username>root</wsse:Username>
> 				<wsse:Password
> Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> username-token-profile-
> 1.0#PasswordDigest">FyjTaK5w90bDNRb5hzWwoaYpX5M=</wsse:Passwor
> d>
> 				<wsse:Nonce
> EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> soap-message-security-
> 1.0#Base64Binary">VNAN0Nuy6gsm6YwAZh8HwA==</wsse:Nonce>
> 				<wsu:Created>2013-02-
> 19T15:16:46.862Z</wsu:Created>
> 			</wsse:UsernameToken>
> 		</wsse:Security>
> 	</soap:Header>
> 	<soap:Body>
> 		<ns10:PullMessages
> xmlns:ns10="http://www.onvif.org/ver10/events/wsdl"
> xmlns:ns11="http://docs.oasis-open.org/wsrf/r-2"
> xmlns:ns2="http://www.w3.org/2005/08/addressing"
> xmlns:ns3="http://docs.oasis-open.org/wsn/b-2"
> xmlns:ns4="http://docs.oasis-open.org/wsrf/bf-2"
> xmlns:ns5="http://docs.oasis-open.org/wsn/t-1"
> xmlns:ns6="http://www.onvif.org/ver10/schema"
> xmlns:ns7="http://www.w3.org/2004/08/xop/include"
> xmlns:ns9="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
> 			<ns10:Timeout>PT60S</ns10:Timeout>
> 			<ns10:MessageLimit>10</ns10:MessageLimit>
> 		</ns10:PullMessages>
> 	</soap:Body>
> </soap:Envelope>
> 
> I just want to add these lines to the header of this/a certain message:
> 
> <wsa5:To
> xmlns:wsa5="http://www.w3.org/2005/08/addressing">http://172.16.101.13
> 0/onvif/services</wsa5:To>
> <dom0:SubscriptionId
> xmlns:dom0="http://www.axis.com/2009/event">3</dom0:SubscriptionId>
> 
> How can I do that? Do you need some more information about my
> implemenetation?
> 
> Thank you!
> 
> meteora28
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Insert-
> elements-in-soap-header-tp5712191p5723378.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message