2013年10月16日星期三

axis2 wsdl2java client can invoke the generated class

axis2 the faithful know , I encountered this problem , hope to solve :
First, I wrote a simple server-side java class , just a plain java class , as follows:
package com.webservice.server;

import java.util.Random;


public class WebServiceServer {

public String sayHello(String name){
return name + "COME ON!!";
}

public int getAge(){
return new Random().nextInt(30);
}


}

, and then through the eclipse plugin axis2 generated services.wsdl file , and then I want to pass this wsdl file automatically generated stub classes , the generated class or into the current project, the project directory structure is as follows , the yellow part is I most original writing service side java class :

WebServiceServerStub.java class has generated an error , because the beginning of the program code is written like this :
 public class WebServiceServerStub extends org.apache.axis2.client.Stub
        implements WebServiceServer{

It put WebServiceServer this class as an interface , but I most primitive defined service -side code is just a regular java class ah ! So I do not understand why this place !
The next problem is that I want to write client code , and want to apply this auto- generated class to write, to see some of the online wording is:

WebServiceServerStub wsss = new WebServiceServerStub();//----1
WebServiceServerStub.SayHello sh = WebServiceServerStub.SayHello();//-----2
sh.setName("小明"); 
System.out.println(wsss.sayHello().get_return());

This should output in the console : Xiao Ming COME ON! !
But the two can not write , WebServiceServerStub. then simply do not find this SayHello class ( the original sayHello method automatically generates a class ) , so please help solve ! Since learning ! Implore help , ()
------ Solution ------------------------------- -------------
LZ, you try to put sayhello that class in your package posted below look okay class class

By the way . LZ try to package with MAVEN AXIS2 look , AAR packages do not generate their own , and direct MVAEN own generated WAR package can be accessed directly , \
------ For reference only ---------------------------------------
how did not answer it ? Top about themselves , seek help !
------ For reference only -------------------------------------- -
no . aar file it
------ For reference only ----------------------------- ----------
bottom is not . aar file Well !
------ For reference only -------------------------------------- -


as I said , as there is no problem, there is no other solution , not maven
------ For reference only ------------- --------------------------
I also seek to solve this problem ah
------ For reference only ---------------------------------------
ask you, how to generate . wsdl document , there is reference to a description of the steps you page ,
I engage in c # , java unskilled operation , thank you

没有评论:

发表评论