Announcement Announcement Module
Collapse
No announcement yet.
Spring for server side code + webservice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Why do you define this?

    Code:
    	<bean id="ear.context" class="org.springframework.context.support.ClassPathXmlApplicationContext">
    		<constructor-arg>
    		<value>/WEB-INF/context.xml</value>
    		</constructor-arg>
    	</bean>
    You can define directly your beans in bean.xml, for example: https://github.com/SpringSource/spri...et-context.xml

    Comment


    • #17
      In github example...it is a complete springproject with all the views defined in WebContent itself.

      I am done with UI part for my project using android and server coding using servlet and other java files.
      Without disturbing the UI , i am just trying to convert the server side to one which fits in springwork.

      Comment


      • #18
        hey...
        <bean id="ear.context" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
        <constructor-arg>
        <value>file:C:\Users\User\workspace\WebProjectTria l\WebContent\WEB-INF\context.xml</value>
        </constructor-arg>
        </bean>

        adding the entire path..its working fine.... but is it the correct way??
        anyways atleast i got something working...

        How do we set the classpath of any WebProject...??
        http://static.springsource.org/sprin...resources.html

        Comment


        • #19
          No, it isn't the correct way, you can define your trial.Controller in bean.xml, you should learn the basic concepts first, see again the link:

          courses.coreservlets.com/Course-Materials/pdf/spring/basics/03-Spring-in-Web-Apps.pdf

          you'll see what you need (applicationContext.xml)

          Comment


          • #20
            Thanks!!
            Got it worked using classpath.
            placing context.xml in WEB-INF/classes and use classpath:context.xml in bean definition.
            Thanks

            Comment


            • #21
              to invoke methods of service class using bean definition

              How do we call a function from a service.java file from bean.
              I am done with constructor using <constructor-arg> tag and for setters <property> tags...
              how a call a method?
              For example:
              Code:
              public class loginService implements loginInterface {
              	@Override
              	public void login_function(String a, String b, String c) {
              		// TODO Auto-generated method stub
              		loginDAO.login(a,b,c);
              		
              	}
              
              }
              in bean.xml file:
              <bean id="login" class="loginService">
              </bean>
              This wont work....
              How do we call a service method from bean and also hoe do we pass parameters to it?

              Comment


              • #22
                i have Mainservlet file in default package..
                also mapped it in web.xml file and added <bean id="main" class="MainServlet"></bean> in beans.xml
                Then why i get the above exception???
                Code:
                SEVERE: Error loading WebappClassLoader
                  delegate: false
                  repositories:
                    /WEB-INF/classes/
                ----------> Parent Classloader:
                org.apache.catalina.loader.StandardClassLoader@4c0da7c3
                 MainServlet
                java.lang.ClassNotFoundException: MainServlet
                	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)
                	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
                	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
                	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
                	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
                	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)

                Comment


                • #23
                  How to Start :-
                  1. Import Maven dependency

                  <dependency>
                  <groupId>net.javacrumbs</groupId>
                  <artifactId>spring-ws-test</artifactId>
                  <version>0.21</version>
                  </dependency>

                  2. Write your test

                  @RunWith(SpringJUnit4ClassRunner.class)
                  //load your standard Spring configuration
                  @ContextConfiguration(locations={"classpath:spring/applicationContext.xml"})
                  //Add the listener
                  @TestExecutionListeners({WsMockControlTestExecutio nListener.class, DependencyInjectionTestExecutionListener.class})
                  public class AirlineWsClient4Test {

                  //inject the class under the test
                  @Autowired
                  private AirlineWsClient client;

                  //inject mock control
                  @Autowired
                  private WsMockControl mockControl;

                  @Test
                  public void testCall()
                  {

                  //teach mock what to do
                  mockControl.expectRequest("expected-request.xml")
                  .returnResponse("response-to-be-returned.xml");

                  //call WS client code
                  long ticketId = client.bookFlight(input,params,here);
                  assertEquals(123456L, ticketId);

                  //verify all the calls
                  mockControl.verify();
                  }

                  }

                  3. And you are done. The library will verify that your Spring configuration is correct, that the request generated by your code corresponds to what you expect and the framework will return the response specified in the "response-to-be-returned.xml" file. Everything in memory, without any HTTP connection so it's reasonably fast.

                  If you need more functional test style configuration, please read functional test reference.
                  Last edited by ericlewis107; Apr 4th, 2012, 07:42 AM. Reason: not written step

                  Comment

                  Working...
                  X