有人请帮我解决这个错误。我是java web服务的新手。我得到如下所述的错误。我正在使用GlassFish服务器和NetBeans IDE。
CalculatorWSApplication a = port.setinfo(name, age);
required: CalculatorWSApplication
found: CalculatorWSApplication_Type
1 error
这是服务器程序
package org.me.calculator;
import com.sun.tools.xjc.api.S2JJAXBModel;
import javax.annotation.*;
import javax.annotation.PreDestroy;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
@WebService(serviceName = "CalculatorWSApplication")
@Stateless()
public class CalculatorWSApplication {
public String firstName;
public String secondName;
/**
* Web service operation
*/
@WebMethod(operationName = "add")
public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k = i + j;
return k;
}
@WebMethod(operationName = "setinfo")
public CalculatorWSApplication setinfo(@WebParam(name = "firstName") String firstName, @WebParam(name = "secondName") String secondName) {
CalculatorWSApplication a = new CalculatorWSApplication();
//TODO write your implementation code here:
System.out.println("Called");
a.firstName = firstName;
a.secondName = secondName;
System.out.println(a.firstName);
System.out.println(a.secondName);
return a;
}
@PostConstruct
public void sayHello(){
System.out.println("Hello");
}
@PreDestroy
public void sayBye(){
System.out.println("Bye");
}
}
这是客户端程序 包含两个Web方法。 第一个是add,它返回整数 第二个是setFirstNameandLastName,它返回CalculatorWSApplication对象。
package calculatorws_client_application;
import org.me.calculator.CalculatorWSApplication;
public class CalculatorWS_Client_Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try{
int i = 3;
int j = 4;
int result = add(i, j);
setFirstNameandLastName("Rajesh","Gubbianna");
System.out.println("Result = " + result);
} catch(Exception ex){
System.out.println("Exception: " + ex);
ex.printStackTrace();
}
}
private static int add(int i, int j) {
org.me.calculator.CalculatorWSApplication_Service service = new org.me.calculator.CalculatorWSApplication_Service();
org.me.calculator.CalculatorWSApplication port = service.getCalculatorWSApplicationPort();
return port.add(i, j);
}
private static void setFirstNameandLastName(String name, String age){
org.me.calculator.CalculatorWSApplication_Service service = new org.me.calculator.CalculatorWSApplication_Service();
org.me.calculator.CalculatorWSApplication port = service.getCalculatorWSApplicationPort();
System.out.println(name + " " + age);
CalculatorWSApplication a = port.setinfo(name, age);
}
}
答案 0 :(得分:0)
boolean,byte,double,float,long,int,javax.activation.DataHandler,java.awt.Image,java.lang.Object,java.lang.String等
有关详细信息和完整的数据类型列表,请查看此链接