File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Webservices calling from struts using threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Webservices calling from struts using threads" Watch "Webservices calling from struts using threads" New topic
Author

Webservices calling from struts using threads

naga eswar
Ranch Hand

Joined: Jan 25, 2012
Posts: 120
Hi all,

I am working on struts application which online sales of Insurance.
Recently we got a CR that we have to integrate with 3 web services which they will generate client number, policy number and receipt number respectively after the user payment has done.
Presently after user payment completed the upload screen will appear.

But now after user payment completed, it should call the 3 web services one after one because client number (generated by first web server ) is the input to second web server which generates policy number and so for third web server also. This all should work at back. The original flow (upload screen will appear after payment) should be as usual, means if any issue in web service connection then it should not effect on original flow. We will track the issue by using logs.

Now client is saying that use thread to call this web services.
First time I am working on threads and struts.
How to call threads from struts frame work.?
Is it ok if I call from action class?
If I call web service from run() method , we can’t return anything from run method.

Can anybody help me please.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

naga eswar wrote:
How to call threads from struts frame work.?


You should not create your own threads in a web application. Use WorkManager, which allows the container to keep control of thread instances.
I'm confused as to what you are trying to accomplish. Do you want to present the user a "processing" page while the transaction completes, then show them the result? If so, use the execute and wait interceptor. If you want to execute the transaction while the user does something else, use the WorkManager. You will have to figure out some other way to inform the user about the results of the transaction. I'm a fan of using email in that case, but you could also devise some flag to signal the user has a message in the application.


[How To Ask Questions On JavaRanch]
naga eswar
Ranch Hand

Joined: Jan 25, 2012
Posts: 120
Thank you for your reply joe.

Finally we decide to not to call web server from threads.
We are using JBOSS 5.1.0 as server
Simply we are calling form Action sub class.
below is the code



If I call this above code as a stand alone application from main() method. Its working.
But after integrating with my application we are facing below issue at code line " String val=stub.doClientEnquiry(req).getStatus(); "

10:11:27,002 INFO [STDOUT] --clientno----50002165
10:11:28,424 ERROR [STDERR] AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTracerg.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages
at org.apache.axis.encoding.DeserializationContext.startDTD(DeserializationContext.java:1161)
at org.apache.xerces.parsers.AbstractSAXParser.doctypeDecl(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.doctypeDecl(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.scanDoctypeDecl(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.cordys.schemas.aviva.laconnector.ClientEnquiryInterfaceStub.doClientEnquiry(ClientEnquiryInterfaceStub.java:229)
at com.avivaindia.wsconnector.ClientData.getClientData(ClientData.java:29)
at com.avivaindia.wsconnector.ClientData.main(ClientData.java:12)
at com.aviva.struts.action.ExistingClientSearchAction.execute(ExistingClientSearchAction.java:105)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

{http://xml.apache.org/axis/}hostname:gurdtp851
10:11:28,424 ERROR [STDERR] org.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages
10:11:28,424 ERROR [STDERR] at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
10:11:28,424 ERROR [STDERR] at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
10:11:28,424 ERROR [STDERR] at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
10:11:28,424 ERROR [STDERR] at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.Call.invoke(Call.java:2767)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.Call.invoke(Call.java:2443)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.Call.invoke(Call.java:2366)
10:11:28,424 ERROR [STDERR] at org.apache.axis.client.Call.invoke(Call.java:1812)
10:11:28,424 ERROR [STDERR] at com.cordys.schemas.aviva.laconnector.ClientEnquiryInterfaceStub.doClientEnquiry(ClientEnquiryInterfaceStub.java:229)
10:11:28,424 ERROR [STDERR] at com.avivaindia.wsconnector.ClientData.getClientData(ClientData.java:29)
10:11:28,424 ERROR [STDERR] at com.avivaindia.wsconnector.ClientData.main(ClientData.java:12)
10:11:28,424 ERROR [STDERR] at com.aviva.struts.action.ExistingClientSearchAction.execute(ExistingClientSearchAction.java:105)
10:11:28,424 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
10:11:28,424 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
10:11:28,424 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
10:11:28,424 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
10:11:28,424 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
10:11:28,424 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
10:11:28,424 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:11:28,424 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
10:11:28,424 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
10:11:28,424 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
10:11:28,424 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
10:11:28,424 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
10:11:28,424 ERROR [STDERR] Caused by: org.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages
10:11:28,424 ERROR [STDERR] at org.apache.axis.encoding.DeserializationContext.startDTD(DeserializationContext.java:1161)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.parsers.AbstractSAXParser.doctypeDecl(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.impl.dtd.XMLDTDValidator.doctypeDecl(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.impl.XMLDocumentScannerImpl.scanDoctypeDecl(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
10:11:28,424 ERROR [STDERR] at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
10:11:28,424 ERROR [STDERR] at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
10:11:28,424 ERROR [STDERR] ... 38 more



can any body help me please.....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

This has nothing to do with Struts. You have a problem with your web service. A quick google search brings up this discussion.
naga eswar
Ranch Hand

Joined: Jan 25, 2012
Posts: 120
Yes Joe....

But the web service is working for other application.
My colleague working on other application developed using with same technologies. Its working fine for him with same code.
I search through Google in so many ways. But I did not get a way out...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webservices calling from struts using threads