Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Spring for server side code + webservice

  1. #21
    Join Date
    Mar 2012
    Posts
    17

    Default

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

  2. #22
    Join Date
    Mar 2012
    Posts
    17

    Default 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?

  3. #23
    Join Date
    Mar 2012
    Posts
    17

    Default

    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)

  4. #24

    Default

    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 at 06:42 AM. Reason: not written step

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •