2

私は、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);

}
4

1 に答える 1

1

実装クラスの @WebService アノテーションで endpointIinterface を指定します。エンドポイント インターフェイスを指定しない場合は、getPort メソッドを使用する際に完全修飾ポート名を指定する必要があります。

MyWSInterface dsws = service.getPort(PortQName,MyWSInterface.class);

于 2013-04-23T18:10:57.077 に答える