Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - problem in concurrent web services -


hi have developed web services. getting problem when 2 different user trying access web services concurrently. in web services 2 methods there

  1. setinputparameter
  2. getuserservice

    suppose

              time               user              operation           10:10           user1             setinputparameter           10:15           user2             setinputparameter           10:20           user1             getuserservice  

user1 getting result according input parameter seted user2 not ( him own )

i using axis2 1.4 ,eclipse ant build, services goes here

  1. user class
  2. service class
  3. service.xml
  4. build file
  5. testclass

package com.jimmy.pojo;   public class user {  private string firstname;  private string lastname;  private string[] addresscity;   public string getfirstname() {   return firstname;  }   public void setfirstname(string firstname) {   this.firstname = firstname;  }   public string getlastname() {   return lastname;  }   public void setlastname(string lastname) {   this.lastname = lastname;  }   public string[] getaddresscity() {   return addresscity;  }   public void setaddresscity(string[] addresscity) {   this.addresscity = addresscity;  }  } [/code]   [code=java]package com.jimmy.service;  import com.jimmy.pojo.user;  public class userservice {  private user user;   public void setinputparameter(user userinput) {   user = userinput;  }   public user getuserservice() {   user.setfirstname(user.getfirstname() + " changed ");   if (user.getaddresscity() == null) {    user.setaddresscity(new string[] { "new city added" });   } else {    user.getaddresscity()[0] = "===========";   }   return user;  }  } [/code]   [code=java]<service name="mywebservices" scope="application">  <description>   web service     </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">com.jimmy.service.userservice  </parameter>  </service>[/code]     [code=java] <project name="mywebservices" basedir="." default="generate.service">  <property name="service.name" value="userservice" />  <property name="dest.dir" value="build" />  <property name="dest.dir.classes" value="${dest.dir}/${service.name}" />  <property name="dest.dir.lib" value="${dest.dir}/lib" />   <property name="axis2.home" value="../../" />  <property name="repository.path" value="${axis2.home}/repository" />  <path id="build.class.path">   <fileset dir="${axis2.home}/lib">    <include name="*.jar" />   </fileset>  </path>  <path id="client.class.path">   <fileset dir="${axis2.home}/lib">    <include name="*.jar" />   </fileset>   <fileset dir="${dest.dir.lib}">    <include name="*.jar" />   </fileset>  </path>  <target name="clean">   <delete dir="${dest.dir}" />   <delete dir="src" includes="com/jimmy/pojo/stub/**"/>  </target>  <target name="prepare">   <mkdir dir="${dest.dir}" />   <mkdir dir="${dest.dir}/lib" />   <mkdir dir="${dest.dir.classes}" />   <mkdir dir="${dest.dir.classes}/meta-inf" />  </target>  <target name="generate.service" depends="clean,prepare">   <copy file="src/meta-inf/services.xml" tofile="${dest.dir.classes}/meta-inf/services.xml" overwrite="true" />   <javac srcdir="src" destdir="${dest.dir.classes}" includes="com/jimmy/service/**,com/jimmy/pojo/**">    <classpath refid="build.class.path" />   </javac>   <jar basedir="${dest.dir.classes}" destfile="${dest.dir}/${service.name}.aar" />   <copy file="${dest.dir}/${service.name}.aar" tofile="${repository.path}/services/${service.name}.aar" overwrite="true" />  </target> </project>  [/code]       [code=java]package com.jimmy.test;  import javax.xml.namespace.qname;  import org.apache.axis2.axisfault; import org.apache.axis2.addressing.endpointreference; import org.apache.axis2.client.options; import org.apache.axis2.rpc.client.rpcserviceclient;  import com.jimmy.pojo.user;  public class mywebservices {  @suppresswarnings("unchecked")  public static void main(string[] args1) throws axisfault {   rpcserviceclient serviceclient = new rpcserviceclient();   options options = serviceclient.getoptions();   endpointreference targetepr = new endpointreference(     "http://localhost:8080/axis2/services/mywebservices");   options.setto(targetepr);   // setting input parameter   qname opsetqname = new qname("http://service.jimmy.com",     "setinputparameter");   user user = new user();   string[] citylist = new string[] { "bangalore", "mumbai" };   /*       need set user 2 user 2    */   user.setfirstname("user 1  first name");   user.setlastname("user 1 last name");   user.setaddresscity(citylist);   object[] opsetinptargs = new object[] { user };   serviceclient.invokerobust(opsetqname, opsetinptargs);    // getting weather   qname opgetweather = new qname("http://service.jimmy.com",     "getuserservice");    object[] opgetweatherargs = new object[] {};   class[] returntypes = new class[] { user.class };    object[] response = serviceclient.invokeblocking(opgetweather,     opgetweatherargs, returntypes);    system.out.println("context :"+serviceclient.getservicecontext());    user result = (user) response[0];    if (result == null) {    system.out.println("user not initialized!");    return;   } else {    system.out.println("*********printing result********");    string[] list =result.getaddresscity();    system.out.println(result.getfirstname());    system.out.println(result.getlastname());    (int indx = 0; indx < list.length ; indx++) {     string string = result.getaddresscity()[indx];     system.out.println(string);    }   }   } } 

it appears me trying maintain state between 2 subsequent calls of webservice. purpose maintaining private field in service class. service class not instantiated on each request getting state shared between users of webservice.

what need store state in kind of session scope. webservice clients need pass-back session token each request.

one way of doing stateful webservices axis 2 detailed here


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -