Axis 2 client

In this tutorial we are going to code an axis 2 client based on wsdl2java approach. We are going to connect to a HighScores Service which we have created in previous tutorial – Axis2 WSDL2Java approach

In this tutorial we are going to discuss following topics:
- Setting up Maven 3 Axis2 project in Eclipse
- Generating client classes from WSDL file
- Using Unit Test for testing client

Setting up Maven 3 Axis2 project in Eclipse

Let’s begin with setting up an eclipse maven project. Follow this steps:

  • In a Project Explorer window right-click and select New -> Project...
  • Pick Maven Project and click Next
  • On the Select project name and location screen select Create a simple project ... and click Next
  • Enter Group Id, Artifact Id and Package (select JAR) values
  • Click Finish

Generating client classes from WSDL file

Ok. Now we are ready to generate WebService client code. Follow this steps:

  • Copy HighScoreService.wsdl (take it from Axis2 WSDL2Java approach) to src/main/resources/wsdl directory
  • add axis2-wsdl2code-maven-plugin to your pom.xml file
<plugin>
 <groupId>org.apache.axis2</groupId>
 <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
 <version>1.6.2</version>
 <executions>
     <execution>
         <goals>
             <goal>wsdl2code</goal>
         </goals>
         <configuration>
             <unpackClasses>true</unpackClasses>
             <databindingName>xmlbeans</databindingName>
             <packageName>com.itcuties.ws</packageName>
             <wsdlFile>src/main/resources/wsdl/HighScoreService.wsdl</wsdlFile>
             <syncMode>sync</syncMode>                                                            
             </configuration>
         </execution>
 </executions>
</plugin>
  • run mvn generate-sources
  • In directory target\generated-sources\axis2\wsdl2code\src you will find newly generated java classes. This is our client code. The most important generated codes are *Stub.java code and the service interface.
  • Almost done. To set all the generated classes in your project classpath enter this configuration to your pom.xml file
<build>
     <resources>
         <resource>
             <directory>src/main/resources</directory>
         </resource>
         <resource>
             <directory>target/generated-sources/axis2/wsdl2code/resources</directory>
         </resource>
     </resources>
...
</build>
…
<dependencies>
     <dependency>
         <groupId>org.apache.axis2</groupId>
         <artifactId>axis2</artifactId>
         <version>1.6.2</version>
     </dependency>
     <dependency>
         <groupId>org.apache.xmlbeans</groupId>
         <artifactId>xmlbeans</artifactId>
         <version>2.5.0</version>
     </dependency>
     <dependency>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-api</artifactId>
         <version>1.2.13</version>
     </dependency>
     <dependency>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-impl</artifactId>
         <version>1.2.13</version>
     </dependency>
     <dependency>
         <groupId>wsdl4j</groupId>
         <artifactId>wsdl4j</artifactId>
         <version>1.6.2</version>
     </dependency>
     <dependency>
         <groupId>org.apache.neethi</groupId>
         <artifactId>neethi</artifactId>
         <version>3.0.2</version>
     </dependency>
     <dependency>
         <groupId>org.apache.axis2</groupId>
         <artifactId>axis2-transport-local</artifactId>
         <version>1.6.1</version>
     </dependency>
     <dependency>
         <groupId>org.apache.axis2</groupId>
         <artifactId>axis2-transport-http</artifactId>
         <version>1.6.1</version>
     </dependency>
     <dependency>
         <groupId>org.apache.ws.commons.schema</groupId>
         <artifactId>XmlSchema</artifactId>
         <version>1.4.7</version>
     </dependency>
     <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.10</version>
     </dependency>
 </dependencies>
  • run mvn eclipse:eclipse
  • Refresh Eclipse project

Using Unit Test for testing client

Now let’s test our generated client we will use unit tests and *Stub class – this is the code that connects to the WebService.
Create a class that will contain methods annotated with @Test annotation. Look at our example code and the comments:

@Test
public void testGetHighScoresForNickname() {
     
   // Use *Stub class to create WebService client
   HighScoreServiceStub stub = null;
   try {
       stub = new HighScoreServiceStub();
   } catch (AxisFault e) {
       e.printStackTrace();
       Assert.fail();
    }

   Assert.assertNotNull(stub);

   // Let's create request document - using axis2 generated classes     
   GetHighScoresForNicknameDocument requestDoc = GetHighScoresForNicknameDocument.Factory.newInstance();
     
   // Create request - class generated by axis2
   GetHighScoresForNickname request = GetHighScoresForNickname.Factory.newInstance();
     
   // Set place a nickname in the request
   request.setNickname("person3");
     
   // Place a request in the request document
   requestDoc.setGetHighScoresForNickname(request);
     
   // Create a response document - class generated by axis2
   GetHighScoresForNicknameResponseDocument responseDoc = null;
    try {
       // Call a WebService operation - getHighScoresForNickname
       responseDoc = stub.getHighScoresForNickname(requestDoc);
    } catch (RemoteException e) {
       e.printStackTrace();
       Assert.fail();
    }
     
    Assert.assertNotNull(responseDoc);
     
   // Get the response from the response document
   GetHighScoresForNicknameResponse response = responseDoc.getGetHighScoresForNicknameResponse();
     
    Assert.assertNotNull(response);
     
   // Get results array from the response object - HighScore class is generated by axis2 and represents highscore data
   HighScore[] result = response.getReturnArray();
     
    Assert.assertNotNull(result);
    Assert.assertTrue(result.length > 0);
     
   // Display the results     
   for (HighScore hs : result) {
       System.out.println(hs.getNickname() + " scores " + hs.getScore());
    }
}

As you can see calling WebService operations is easy with the generated *Stub class.
Run mvn test to test your solution.

Download this sample code here.

4 Responses to "Axis 2 client"

  1. tikoti says:

    Hi!!!

    Truly amazing tutorial you have done here

    I have one issue though

    After following thouroughly the tutorials I get the result attached at the end of this post, as you can see even though the items are returned correctly by the webservice, the values appear to be null when posting them.

    Also I can see in the eclipse console that the webservice is returning the propper values!

    Could you please help me? It is the only issue I have left for finishing this correctly!

    Thank you in advance!!

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.itcuties.ws.service.HighScoreServiceTest
    23-oct-2013 13:31:30 org.apache.axis2.deployment.ModuleDeployer deploy
    INFO: Deploying module: addressing-1.6.2 - file:/C:/Development/maven-repo/org/
    pache/axis2/axis2/1.6.2/axis2-1.6.2.jar
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    null scores 0
    23-oct-2013 13:31:31 org.apache.axis2.deployment.ModuleDeployer deploy
    INFO: Deploying module: addressing-1.6.2 - file:/C:/Development/maven-repo/org/
    pache/axis2/axis2/1.6.2/axis2-1.6.2.jar
    23-oct-2013 13:31:32 org.apache.axis2.deployment.ModuleDeployer deploy
    INFO: Deploying module: addressing-1.6.2 - file:/C:/Development/maven-repo/org/
    pache/axis2/axis2/1.6.2/axis2-1.6.2.jar
    null scores 0
    23-oct-2013 13:31:32 org.apache.axis2.deployment.ModuleDeployer deploy
    INFO: Deploying module: addressing-1.6.2 - file:/C:/Development/maven-repo/org/
    pache/axis2/axis2/1.6.2/axis2-1.6.2.jar
    There is 12 highscores on the list.
    Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.546 sec
    
    Results :
    
    Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 10.859s
    [INFO] Finished at: Wed Oct 23 13:31:32 CEST 2013
    [INFO] Final Memory: 11M/53M
    [INFO] ------------------------------------------------------------------------
    
    Reply
  2. hina says:

    When i run maven test,i get the below error in the console.Can anyone tell me where im going wrong?

    [INFO] Scanning for projects...
    [INFO] 
    [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building HighScoresServiceClient 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HighScoresServiceClient ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO] Copying 426 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ HighScoresServiceClient ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HighScoresServiceClient ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ HighScoresServiceClient ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HighScoresServiceClient ---
    [INFO] Surefire report directory: C:\Users\Hina\workspace1\HighScoresServiceClient\target\surefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.itcuties.ws.service.HighScoreServiceTest
    Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.237 sec &lt;&lt;&lt; FAILURE!
    getHighScoresSize(com.itcuties.ws.service.HighScoreServiceTest)  Time elapsed: 0.025 sec  &lt;&lt;&lt; ERROR!
    java.lang.Error: Unresolved compilation problems: 
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.ws.HighScoreServiceStub cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved
    	GetHighScores cannot be resolved to a type
    	GetHighScores cannot be resolved
    	GetHighScoresResponseDocument cannot be resolved to a type
    	GetHighScoresResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved
    	AddHighScore cannot be resolved to a type
    	AddHighScore cannot be resolved
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved
    	GetHighScoresForNickname cannot be resolved to a type
    	GetHighScoresForNickname cannot be resolved
    	GetHighScoresForNicknameResponseDocument cannot be resolved to a type
    	GetHighScoresForNicknameResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved
    	GetHighScoresSize cannot be resolved to a type
    	GetHighScoresSize cannot be resolved
    	GetHighScoresSizeResponseDocument cannot be resolved to a type
    	GetHighScoresSizeResponse cannot be resolved to a type
    
    	at com.itcuties.ws.service.HighScoreServiceTest.(HighScoreServiceTest.java:9)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
    
    testGetHighScoresForNickname(com.itcuties.ws.service.HighScoreServiceTest)  Time elapsed: 0.004 sec  &lt;&lt;&lt; ERROR!
    java.lang.Error: Unresolved compilation problems: 
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.ws.HighScoreServiceStub cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved
    	GetHighScores cannot be resolved to a type
    	GetHighScores cannot be resolved
    	GetHighScoresResponseDocument cannot be resolved to a type
    	GetHighScoresResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved
    	AddHighScore cannot be resolved to a type
    	AddHighScore cannot be resolved
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved
    	GetHighScoresForNickname cannot be resolved to a type
    	GetHighScoresForNickname cannot be resolved
    	GetHighScoresForNicknameResponseDocument cannot be resolved to a type
    	GetHighScoresForNicknameResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved
    	GetHighScoresSize cannot be resolved to a type
    	GetHighScoresSize cannot be resolved
    	GetHighScoresSizeResponseDocument cannot be resolved to a type
    	GetHighScoresSizeResponse cannot be resolved to a type
    
    	at com.itcuties.ws.service.HighScoreServiceTest.(HighScoreServiceTest.java:9)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
    
    testGetHighScores(com.itcuties.ws.service.HighScoreServiceTest)  Time elapsed: 0.004 sec  &lt;&lt;&lt; ERROR!
    java.lang.Error: Unresolved compilation problems: 
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.ws.HighScoreServiceStub cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved
    	GetHighScores cannot be resolved to a type
    	GetHighScores cannot be resolved
    	GetHighScoresResponseDocument cannot be resolved to a type
    	GetHighScoresResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved
    	AddHighScore cannot be resolved to a type
    	AddHighScore cannot be resolved
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved
    	GetHighScoresForNickname cannot be resolved to a type
    	GetHighScoresForNickname cannot be resolved
    	GetHighScoresForNicknameResponseDocument cannot be resolved to a type
    	GetHighScoresForNicknameResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved
    	GetHighScoresSize cannot be resolved to a type
    	GetHighScoresSize cannot be resolved
    	GetHighScoresSizeResponseDocument cannot be resolved to a type
    	GetHighScoresSizeResponse cannot be resolved to a type
    
    	at com.itcuties.ws.service.HighScoreServiceTest.(HighScoreServiceTest.java:9)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
    
    testAddHighScore(com.itcuties.ws.service.HighScoreServiceTest)  Time elapsed: 0.006 sec  &lt;&lt;&lt; ERROR!
    java.lang.Error: Unresolved compilation problems: 
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.serivces cannot be resolved
    	The import com.itcuties.ws.HighScoreServiceStub cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved to a type
    	GetHighScoresDocument cannot be resolved
    	GetHighScores cannot be resolved to a type
    	GetHighScores cannot be resolved
    	GetHighScoresResponseDocument cannot be resolved to a type
    	GetHighScoresResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved to a type
    	AddHighScoreDocument cannot be resolved
    	AddHighScore cannot be resolved to a type
    	AddHighScore cannot be resolved
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved to a type
    	GetHighScoresForNicknameDocument cannot be resolved
    	GetHighScoresForNickname cannot be resolved to a type
    	GetHighScoresForNickname cannot be resolved
    	GetHighScoresForNicknameResponseDocument cannot be resolved to a type
    	GetHighScoresForNicknameResponse cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScore cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	HighScoreServiceStub cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved to a type
    	GetHighScoresSizeDocument cannot be resolved
    	GetHighScoresSize cannot be resolved to a type
    	GetHighScoresSize cannot be resolved
    	GetHighScoresSizeResponseDocument cannot be resolved to a type
    	GetHighScoresSizeResponse cannot be resolved to a type
    
    	at com.itcuties.ws.service.HighScoreServiceTest.(HighScoreServiceTest.java:9)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:483)
    	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
    
    
    Results :
    
    Tests in error: 
      getHighScoresSize(com.itcuties.ws.service.HighScoreServiceTest): Unresolved compilation problems: (..)
      testGetHighScoresForNickname(com.itcuties.ws.service.HighScoreServiceTest): Unresolved compilation problems: (..)
      testGetHighScores(com.itcuties.ws.service.HighScoreServiceTest): Unresolved compilation problems: (..)
      testAddHighScore(com.itcuties.ws.service.HighScoreServiceTest): Unresolved compilation problems: (..)
    
    Tests run: 4, Failures: 0, Errors: 4, Skipped: 0
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 20.567 s
    [INFO] Finished at: 2015-05-12T10:07:52-08:00
    [INFO] Final Memory: 10M/112M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project HighScoresServiceClient: There are test failures.
    [ERROR] 
    [ERROR] Please refer to C:\Users\Hina\workspace1\HighScoresServiceClient\target\surefire-reports for the individual test results.
    [ERROR] -&gt; [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    
    
    Reply
  3. hina says:

    I would like to add….i have downlaoded the project and then impot it into eclipse.Then the HighScoreServiceTest.java file is marked red and folders,files etc in the target folder cannot be generated.But when i delete the HighScoreServiceTest.java file,files and folders in the target folder are generetaed and it works fine.But as i bring back the HighScoreServiceTest.java file its marked red and i get the above error msg as i run maven test.Please help me with this issue?

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>