We are having a apache cxf web service. I wrote an inInterceptor which logs the headers to the console.
Our web service has layers like service,serviceImpl......dao
Whre we struck is, we want one of the headers (which is unique for each request) available at DAO.
Is there a way I can achieve this?
You can retrieve the current CXF Message using PhaseInterceptorChain.getCurrentMessage(). Once you have the message, you can retrieve the headers just like you would in an Interceptor. For example:
Message message = PhaseInterceptorChain.getCurrentMessage();
Map<String, List<String>> headers = (Map<String, List<String>>) message
.get(Message.PROTOCOL_HEADERS);
Related
I'm using curl to test my Web services sending SOAP Request. Right now I need some UI tools to generate the sample SOAP Request to be sent. Is there any shell tool (Fedora/RHEL) which lets you generate a SOAP Request from a WSDL ?
Thanks
Check this out, it is a download link for the new SOAP UI tool with added functionality you might require if you don't have it already.
https://sourceforge.net/projects/soapui/
I want to build a logger that logs all incoming requests and their response to a database. For this I created an axis2 module that should do this in the Inflow and the Outflow - I do not want to trigger the logging from the sequences, because then I would need to put the logger in all my services.
My problem is: how can I relate the incoming message in ESB to the return message? I think this is where Synapse comes in, but I cannot find the right properties to link the messages together: there is no messageId or correlationid that I can use to do this.
Is there a way to access the Synapse properties of the message in the axis2 handler?
Axis2 module is a right option. To identify request and responses, you can check the messageIDs. And if you want to access request messagecontext in the relavant responsemessage context try following code block;
MessageContext requestMessageCtx = responseMessageCtx.getOperationContext()
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Here is a blog post
This is critical to my current project. I have written a client in C++ using Windows web services. This client talks to the Clickatell SMS SOAP web service. I have tested the request using the SOAPUI tool and get correct response. I also receive the SMS message. Now, when I do this programmatically it fails because the WsCall() [in the code generated from WSDL via wsutil.exe) inserts even though the SOAP request I have already includes Envelope and Body. I cannot take out my Envelope since I have namespace specified in it like this:
http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:tns=\"soap.clickatell.com\">
I know that the additional Envelope and Body are inserted since I see it in the Fiddler tool.
Any help I can get is highly appreciated!
Looks like you are using the older type rpc/encoded soap api.
Have you tried using the document/literal service?
(http://api.clickatell.com/soap/document_literal/webservice.php?wsdl)
I have implemented a Spring WS using XWSS for security. I have added a security configuration policy file into my application.
<xwss:SecurityConfiguration xmlns:xwss="http://java.sun.com/xml/ns/xwss/config"
dumpMessages="true">
<xwss:RequireTimestamp
id="tsp"
maxClockSkew="60"
timestampFreshnessLimit="300">
</xwss:RequireTimestamp>
<xwss:RequireUsernameToken
id="token"
passwordDigestRequired="false"
nonceRequired="false"/>
<xwss:Timestamp></xwss:Timestamp>
<xwss:UsernameToken
name="service"
password="service"
id="uToken"
digestPassword="true"
useNonce="true"/>
</xwss:SecurityConfiguration>
Now I am developing a client to access the WS. The security works fine. But I am unable to test the SUCCESS case in which the client can successfully get a response from my service. The problem is I don't know how to make my client send the usernametoken and timestamp along with the request. I am using NetBeans IDE and I am implementing a JAX-WS client to access the Spring WS using this tutorial.
Please let me know what needs to be done.
For Spring WSS there is not much difference between adding a security header to the ingoing soap messages or to the outgoing ones. The process is very similar.
In both cases, you should create a interceptor for adding the security header. It is described here. So, if you create the WS client using Spring you should not have problems, especially if you have already developed the server side, but the tutorial you referenced doesn't look like using Spring for implementing the client.
You can do this by adding the following code in you client class / class extending the webservicetgatewaysupport.
SoapHeader header = msg.getSoapHeader();
StringSource headerSource = new StringSource("<wsse:Security xmlns:wsse=\"http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" mustUnderstand=\"1\"> <wsse:UsernameToken>
<wsse:Username>"+userName+"</wsse:Username> <wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/
oasis-200401-wss-username-token-profile-1.0#PasswordText\">"+password+"</wsse:Password> </wsse:UsernameToken>"
+"</wsse:Security>");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(headerSource, header.getResult());
The above has to go in the message call back handler of the marshalSendANDRecieve metho of the webserviceTemplate
Check this sample for client.
And you could use SoapUI to test your server. Import WSDL, then select any request and open "Properties" window in left-bottom corner. You would see "Username", "Password" and "WSS-Password Type" related settings.
I generated a client using the weblogic.wsee.tools.anttasks.ClientGenTask from weblogic. Now I want to insert custom soap headers before sending out the request. How do I go about doing that? All of the examples on the web for inserting headers are specific to the library used in the generation (Axis, etc).
Thanks!
http://download.oracle.com/docs/cd/E13222_01/wls/docs90/webserv/client.html
Google "Client Handler Chain". Extend GenericHandler and setup a handler xml before generating your client.
Cheers!