0

Java で非同期 Web サービスにアクセスするにはどうすればよいですか? 私はこれを Flex Builder で作成しましたが、非常に簡単です。Web サービスを追加して、"Data -> Connect to Web Service -> Enter the URL of wsdl" をスローし、次の行を追加するだけです。

private function result(e:ResultEvent):void
{
     trace(e.result.toString());
}

private function fault(e:FaultEvent):void
{
     trace(e.toString());
}

var d:DomainAuth = new DomainAuth();
d.AuthFuncName(login, pass);
d.addEventListener(ResultEvent.RESULT, result);
d.addEventListener(FaultEvent.FAULT, fault);

Eclipse EEを使用してJavaでこれを行うにはどうすればよいですか?

4

1 に答える 1

0

基本的に、私が正しく理解していれば、Java で SOAP Web サービス クライアントを実行する必要があります。JAX-WS はあなたの友達になることができます。以下のコードはこちらから

package simpleclient;

import javax.xml.ws.WebServiceRef;
import helloservice.endpoint.HelloService;
import helloservice.endpoint.Hello;

public class HelloClient {
    @WebServiceRef(wsdlLocation="http://localhost:8080/
        helloservice/hello?wsdl")
    static HelloService service;

  public static void main(String[] args) {
    try {
        HelloClient client = new HelloClient();
        client.doTest(args);
    } catch(Exception e) {
        e.printStackTrace();
    }
}

public void doTest(String[] args) {
    try {
        System.out.println("Retrieving the port from
                 the following service: " + service);
        Hello port = service.getHelloPort();
        System.out.println("Invoking the sayHello operation
                 on the port.");

        String name;
        if (args.length > 0) {
            name = args[0];
        } else {
            name = "No Name";
        }

        String response = port.sayHello(name);
        System.out.println(response);
    } catch(Exception e) {
        e.printStackTrace();
    }
  }
}
于 2013-04-30T09:53:44.630 に答える