私は、localhost で Web サービスを実行しているプロジェクトに取り組んでいます。これにはjax-wsを使用しました。サーバーと同じプロジェクトにクライアントがあった場合、問題なく動作しました。しかし、今、新しいクライアント プロジェクトを作成しようとしていますが、実行しようとすると次のエラーが発生します。
Undefined port type: {http://test.main/}MyWSInterface
私は両方のクラスでインターフェースをコピーしました:
package main.test;
import javax.activation.DataHandler; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public interface MyWSInterface {
@WebMethod public void sendTask(String convertType, String outputFileName, DataHandler dH);
}
メインのテスト メソッドの次の行でこのエラーが発生します。
MyWSInterface dsws = service.getPort(MyWSInterface.class);
このメソッドの 4 行目は次のとおりです。
private void runTest() throws MalformedURLException {
URL url = new URL("http://localhost:8080/MyWS?wsdl");
QName qname = new QName("http://ws.sender.something.somecompany.com/", "MyWSInterfaceImplService");
Service service = Service.create(url, qname);
DocShifterWS dsws = service.getPort(DocShifterWS.class);
FileDataSource ds = new FileDataSource(new File("C:\\temp\\testinput.txt\\"));
DataHandler dh = new DataHandler(ds);
dsws.sendTask("pdf", "something.pdf", dh);
}