[JBossWS] - sending Soap message with timeout
by sbutt
Hi Folks,
I have implemented a basic soap client (javax.xml.soap.*).
|
| public Message processSOAPRequest(Message message) {
| try {
| MessageFactory msgFactory = MessageFactory.newInstance();
| SOAPMessage soap = msgFactory.createMessage();
| SOAPPart soapPart = soap.getSOAPPart();
|
| byte[] buffer = ((String) message.getBody().get()).getBytes();
| ByteArrayInputStream stream = new ByteArrayInputStream(buffer);
| StreamSource source = new StreamSource(stream);
| soapPart.setContent(source);
| String action = config.getAttribute(SOAP_ACTION);
| if (action != null) {
| MimeHeaders headers = soap.getMimeHeaders();
| headers.addHeader("SOAPAction", action);
| }
|
| /////////////////////////////////////////////////////////
|
| SOAPMessage reply = sendSOAPMessage(soap);
|
| /////////////////////////////////////////////////////////
|
| ByteArrayOutputStream out = new ByteArrayOutputStream();
| reply.writeTo(out);
| String soapMessage = new String(out.toByteArray());
| message.getBody().add(soapMessage);
|
| } catch (SOAPException e) {
| logger.error("SOAPException : " + e);
|
| } catch (IOException e) {
| logger.error("IOException : " + e);
| }
|
| return message;
|
| }
|
|
| private SOAPMessage sendSOAPMessage(SOAPMessage soap) {
| SOAPConnection connection = null;
| SOAPMessage reply = null;
| try {
| SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory
| .newInstance();
| connection = soapConnFactory.createConnection();
| String destination = config.getAttribute(URL_ENDPOINT);
|
| reply = connection.call(soap, destination);
|
|
|
| } catch (Exception e) {
| logger.error(e);
| } finally {
| try {
| if (connection != null) {
| connection.close();
| }
| } catch (SOAPException e) {
| logger.error(e);
| }
| }
|
| return reply;
| }
|
|
The input message is JBossEsb message, which I convert to soap message and then send it using SOAPConnection, which works fine.
The problem with SOAPConnection class is that it does not provide setTimeout(..) method. I read some where that there is another class SOAPConnectionImpl (by axis), which extends SOAPConnection and has this setTimeout method.
I have tried to convert my existing implementation to SOAPConnectionImpl but i always get a classcast exceptions.
Could somebody help me in suggesting a solution to this problem? My main concern is to include timeout feature that is my WS consumer/client should timeout after a certain period if the server does not reply.
Any other soap message sending implementation with timeout feature are also good.
I have included
| <dependency>
| <groupId>axis</groupId>
| <artifactId>axis</artifactId>
| <version>1.4</version>
| </dependency>
|
maven dependencies for axis.
Awaiting replies.
Thanks.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241472#4241472
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241472
15 years, 6 months
[JBossWS] - Re: Newlines/spaces in SOAPMessage
by alfred.rsa
Using WireShark to intercept the transmission, I found that the JBoss SOAPElement.setvalue implementation seems
to add a carriage return linefeed combination to my text which causes the Web Service to crash:
0000 37 32 0d 0a 3c 65 6e 76 3a 45 6e 76 65 6c 6f 70 72..<env:Envelop
| 0010 65 20 78 6d 6c 6e 73 3a 65 6e 76 3d 27 68 74 74 e xmlns:env='htt
| 0020 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 p://schemas.xmls
| 0030 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e 76 oap.org/soap/env
| 0040 65 6c 6f 70 65 2f 27 3e 3c 65 6e 76 3a 42 6f 64 elope/'><env:Bod
| 0050 79 3e 3c 73 65 61 72 63 68 44 6f 63 44 61 74 61 y><searchDocData
| 0060 52 65 71 75 65 73 74 3e 3c 66 5f 6e 72 3e 74 65 Request><f_nr>te
| 0070 73 74 5f 66 6e 6f 0d 0a st_fno..
When I use Sun's SAAJ this doesnot happen
Any ideas?
Regards Alfred
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241399#4241399
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241399
15 years, 6 months
[JBossWS] - Newlines/spaces in SOAPMessage
by alfred.rsa
Hi guys
I have code that works when I call it from a stand-alone application, but when I call it from within JBoss, I get a NPE from the Web service I am calling.
The problem seems to be newline or space characters between the XML tags of the SOAP message. When I use the stand-alone code I get the following output from SOAPMessage().writeTo(System.out)
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><searchDocDataRequest><f_nr>test_fno</f_nr><userid>cnt_usr</userid><items><cheque format="tiff"><account_nr>62001869538</account_nr></cheque></items></searchDocDataRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
>From within JBoss I get:
| 13:41:03,491 INFO [STDOUT] <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Body><searchDocDataRequest><f_nr>test_fno
| 13:41:03,491 INFO [STDOUT] </f_nr>
| 13:41:03,491 INFO [STDOUT] <userid>cnt_usr
| 13:41:03,491 INFO [STDOUT] </userid>
| 13:41:03,507 INFO [STDOUT] <items><cheque format='tiff'><account_nr>62001869538
| 13:41:03,507 INFO [STDOUT] </account_nr>
| 13:41:03,507 INFO [STDOUT] </cheque>
| 13:41:03,507 INFO [STDOUT] </items>
| 13:41:03,523 INFO [STDOUT] </searchDocDataRequest>
| 13:41:03,523 INFO [STDOUT] </env:Body></env:Envelope>
The only difference being the prefix and the newline/space.
Does anybody have any idea on how I can remove this?
Reards
Alfred
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241183#4241183
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241183
15 years, 6 months