2013年9月28日星期六

axis2 problem calling webservice method parameter parameter is empty



//测试代码
public static void main(String[] args) {
        try {
            RPCServiceClient rpcClient = new RPCServiceClient();
            Options options=rpcClient.getOptions();
            options.setTo(new EndpointReference("http://localhost:8081/WebServiceT/WebServiceT?wsdl"));
           
             Object[] objects = new Object[] { 1,2 };    
             Class<?>[] classes = new Class[] { int.class }; 
             QName qname = new QName("http://web.sdl.com/", "add");  
              int result = (int) rpcClient.invokeBlocking(qname, objects, classes)[0];  
             System.out.println(result);  
         
        } catch (AxisFault ex) {
            Logger.getLogger(JavaApplication5.class.getName()).log(Level.SEVERE, null, ex);
        }
    }




@WebService(serviceName = "WebServiceT")
@Stateless()
public class WebServiceT {
    /**
     * This is a sample web service operation
     */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        System.out.println("txt="+txt);
        return "Hello " + txt + " !";
    }
    
    @WebMethod(operationName = "add")
    public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
        int k = i + j;
        return k;
    }
    
     @WebMethod(operationName = "test")
    public String add2(@WebParam(name = "a") String i, @WebParam(name = "b") int j) {
//        int k = i + j;
         System.out.println("j="+j);
        return "fsdfadsfdsf"+i;
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "add3")
    public String add3(@WebParam(name = "s") Integer s) {
        //TODO write your implementation code here:
         System.out.println("s="+s.intValue());
        return s+"sdfdsf";
    }


Why does every passing parameters are empty ah ?
------ Solution ---------------------------------------- ----
new EndpointReference where the address should be without ? wsdl , and you then try to remove
------ For reference only ------------ ---------------------------
ah, I had to use axis1.4 can also pass a parameter of type String , and now nothing can not pass the
------ For reference only ----------------------------------- ----
how no one to speak it ?
------ For reference only -------------------------------------- -
(@ WebParam (name = "i") int i, @ WebParam (name = "j") int j)
axis2 service call java6 released when the method parameter annotation @ WebParam need to remove .
directly above sentence deleted or commented out. And then re-released under the call on OK

your original method parameters that the service class parameters gave comments. Is to give xfire call . If the method parameter annotation @ WebParam
removed. xfire will appear parameter is empty .

there are kinds of way is for species called.

The reason may be xfire than axis2 wsdl document specification requirements in multi- parameter piece something . I did not specifically look at in depth . To use CXF company behind it. Good luck !
------ For reference only -------------------------------------- -
no way you solve ? ?

------ For reference only ---------------------------------- -----
call.addParameter ("xmlStr", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType (XMLType.XSD_STRING);

I resolved, before calling together these two lines of code , meaning that you want to pass parameters to develop , as well as return type of the result . .
------ For reference only -------------------------------------- -


This is your axis1.4 version of it . axis2 seem insurmountable. I have encountered this problem.
------ For reference only -------------------------------------- -
I solved this problem . AXIS2 call CXF server method must be coupled into the reference parameter namespace as follows:
	@WebMethod	
public String operatorONUPort(
@WebParam(name="inparam",mode=WebParam.Mode.IN,targetNamespace="http://XXXXX/")
                String inparam){
logger.info("PON业务方法开始,输入参数:"+inparam);


------ For reference only ---------------------------------- -----
this problem has troubled me for two days , and finally was I tried out. I hope for your help ! ! !

没有评论:

发表评论