java - Axis2 problem with concurrent requests mismatch response object -


i'm facing problem on production server web service concurrent requests.

the problem when web service receives (for instance) 2 requests 2 different methods (each method returning different object) in same service, web service return object type of second request.

to replicate , problem create simple web service 1 service , 2 methods same environment of production server.

code (requestmethods.class)

package test;  import beans.request1response; import beans.request2response;  public class requestmethods {      public request1response request1() {         request1response output = new request1response();          try {             thread.sleep(10 * 1000);         } catch (interruptedexception e) {             e.printstacktrace();         }          output.seterror_code(1);         output.seterror_msg("message1");          return output;     }      public request2response request2() {         request2response output = new request2response();          output.seterror_code(2);         output.seterror_msg("message2");          return output;     }  } 

configurations (services.xml)

<service name="requestmethods">     <description>         concurrent requests test     </description>     <messagereceivers>         <messagereceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.rpcinonlymessagereceiver" />         <messagereceiver  mep="http://www.w3.org/2004/08/wsdl/in-out"  class="org.apache.axis2.rpc.receivers.rpcmessagereceiver"/>     </messagereceivers>     <parameter name="serviceclass" locked="false">test.requestmethods</parameter> </service> 

test

i've made request request1 , before 1 returns, made request request2.

result request1 (the first request second obtained response):

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">    <soapenv:body>       <ns:request2response xmlns:ns="http://test/xsd">          <ns:return>             <error_code xmlns="http://beans/xsd">1</error_code>             <error_msg xmlns="http://beans/xsd">message1</error_msg>          </ns:return>       </ns:request2response>    </soapenv:body> </soapenv:envelope> 

result request2 (the second request first obtained response):

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">    <soapenv:body>       <ns:request2response xmlns:ns="http://test/xsd">          <ns:return>             <error_code xmlns="http://beans/xsd">2</error_code>             <error_msg xmlns="http://beans/xsd">message2</error_msg>          </ns:return>       </ns:request2response>    </soapenv:body> </soapenv:envelope> 

as can see above, response request1 should of type request1response it's request2response instead.

the environment i'm using is:

  • tomcat 5.5.25 application server
  • axis2 1.2 web service
  • java version 1.5.0_11

is facing problem or knows how solve it? tried change axis2 version 1.6 problem persists.

any appreciated.

regards, joão

found solution problem.

when have service (requestmethods) more 1 method defined (request1 , request2), it's necessary set 1 rpcmessagereceiver each method avoid concurrency problems.

you can define 1 messagereceiver each method on file services.xml.

in example post, file services.xml should this:

services.xml

<service name="requestmethods">     <description>         concurrent requests test     </description>     <operation name="request1">          <messagereceiver  mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.rpcmessagereceiver"/>      </operation>     <operation name="request2">          <messagereceiver  mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.rpcmessagereceiver"/>      </operation>      <parameter name="serviceclass" locked="false">test.requestmethods</parameter> </service> 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -