誰かが私が得るこのエラーを乗り越えるのを手伝ってください。私は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");
}
}
これがクライアント プログラムです。2 つの Web メソッドが含まれています。1 つ目は am Integer を返す add です。2 つ目は CalculatorWSApplication オブジェクトを返す setFirstNameandLastName です。
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);
}
}