Я столкнулся с проблемой, связанной с wsgen, который генерирует org.my.ws.FileDataSource
вместо использования javax.activation.FileDataSource
Я ищу Какие настройки / конфигурация должны быть выполнены, чтобы *Будет использоваться 1006 *?
Конфигурация:
jdk 8 - 152
wsgen 2.2.9
Команды компиляции:
Сервер:
javac org\my\ws\MyService.java
wsgen -verbose -keep -cp . org.my.ws.MyService
wsgen -verbose -keep -cp . org.my.ws.MyService -wsdl
javac org\my\endpoint\WsPublisher.java
java org.my.endpoint.WsPublisher
Клиент:
wsimport -keep -verbose http://localhost:8898/ws/server?wsdl
javac ServerInfoClient.java
Ниже приведен фрагмент кода
1) MyService.java
package org.my.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.WebParam;
@WebService
public class MyService{
@WebMethod(operationName="processList")
public boolean processList(@WebParam(name = "processList") java.util.ArrayList al) {
System.out.println("*** ArrayList: " + al);
return true;
}
@WebMethod(operationName="pFile")
public boolean pFile (@WebParam(name = "pFile") java.io.File pFile)
{
String name = pFile.getName();
System.out.println("*** pFile: " + name);
return true;
}
@WebMethod(operationName="processFile")
public boolean processFile (@WebParam(name = "fileDS") javax.activation.FileDataSource fileDS)
{
String name = fileDS.getName();
System.out.println("*** file Name: " + name);
return true;
}
}
2) MyServiceClient.java
import org.my.ws.MyServiceService;
import org.my.ws.MyService;
public class MyServiceClient
{
public static void main(String[] args) {
MyServiceService service = new MyServiceService();
MyService port = service.getMyServicePort();
java.util.ArrayList al1 =new java.util.ArrayList();
System.out.println("Processing ArrayList: " + port.processList(al1));
java.io.File f1 = new java.io.File("new1.txt");
System.out.println("Processing C File: " + port.pFile(f1));
java.io.File file = new java.io.File ("temp1.txt");
javax.activation.FileDataSource fds = new
javax.activation.FileDataSource(file);
System.out.println("Processing file: " + port.processFile(fds));
System.out.println("Done...");
}
}
3) WsPublisher.java
package org.my.endpoint;
import javax.xml.ws.Endpoint;
import org.my.ws.MyService;
//Endpoint publisher
public class WsPublisher{
public static void main(String[] args) {
Endpoint.publish("http://localhost:8898/ws/server", new MyService());
System.out.println("Service is published!!!");
}
}
Журнал ошибок:
D:\>javac MyServiceClient.java -Xdiags:verbose
MyServiceClient.java:15: error: method pFile in interface MyService cannot
be applied to given types;
System.out.println("Processing C File: " + port.pFile(f1));
^
required: String
found: File
reason: argument mismatch; File cannot be converted to String
MyServiceClient.java:20: error: method processFile in interface MyService
cannot be applied to given types;
System.out.println("Processing file: " + port.processFile(fileDS));
^
required: org.my.ws.FileDataSource
found: javax.activation.FileDataSource
reason: argument mismatch; javax.activation.FileDataSource cannot be
converted to org.my.ws.FileDataSource
Note: MyServiceClient.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
wsdl генерируется автоматически, я не ищу ручное редактирование wsdl
Спасибо.