2011-08-10 9 views
0

アクセス可能なWebサービスがあるかどうかを確認するにはどうすればよいですか?
Webサービスに存在するメソッド名を知っているサービスのリストも見ることができます。しかし、メソッドが受け入れるパラメータはわかりません。
ここで私はhttp://machine_name/war_name/services/service_name/getChildren?a のようなものを試してみましたが、次のエラーWebサービスにアクセスできるかどうかを確認する方法?

soapenv:Fault> 
<faultcode>soapenv:Client</faultcode> 
− 
<faultstring> 
Umarshaller error: Error during unmarshall <getChildren><a></a></getChildren>; nested exception is: 
    edu.harvard.i2b2.common.exception.I2B2Exception: Umarshaller error: Error during unmarshall <getChildren><a></a></getChildren>; nested exception is: 
    org.apache.axis2.AxisFault: Umarshaller error: Error during unmarshall <getChildren><a></a></getChildren>; nested exception is: 
    edu.harvard.i2b2.common.exception.I2B2Exception: Umarshaller error: Error during unmarshall <getChildren><a></a></getChildren> 
</faultstring> 
<detail/> 
</soapenv:Fault> 

を得たウェブサービス

public OMElement getChildren(OMElement paramOMElement) 
    { 
    Object localObject2 = paramOMElement.toString(); 
    // Some other stuff 
    } 

に存在する方法は、このエラーです私はサービスにアクセスできるようにしています意味が、間違った引数を送信?
また、サービスにはWSDLファイルがありません。
サービスがアクセス可能かどうか、または必要な正確なパラメータを見つける方法を確認するにはどうすればよいですか?

答えて

3

サービスにリクエストを送信し、応答があり、例外もなく、サーバーが動作していることを確認する必要があります。 NtはJavaでコーディングするのが快適ですが、こちらはC#の抜粋です:

function bool CheckIfServiceIsAlive(string url) 
{ 
var isServiceUrlAlive= false; 
      var req = WebRequest.Create(url); 
      if (!string.IsNullOrEmpty(proxyServer)) 
      { 
       var proxy = new WebProxy(proxyServer, 8080) { Credentials = req.Credentials }; //if you need to use a proxy 
       WebRequest.DefaultWebProxy = proxy; 
       req.Proxy = proxy; 
      } 
      else 
      { 
       req.Proxy = new WebProxy(); 
      } 
      try 
      { 
       var response = (HttpWebResponse)req.GetResponse(); 
       isServiceUrlAlive= true; 
      } 
      catch (WebException) { } 

      return isServiceUrlAlive; 
Apache Commons UrlValidatorクラス

UrlValidator urlValidator = new UrlValidator(); 
urlValidator.isValid("http://<your service url>"); 

または応答コードを取得します。このような方法を使用するを使用してのようなJavaのための容易な解決策があるかもしれません

public static int getResponseCode(String urlString) throws MalformedURLException, IOException { 
    URL u = new URL(urlString); 
    HttpURLConnection huc = (HttpURLConnection) u.openConnection(); 
    huc.setRequestMethod("GET"); 
    huc.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)"); 
    huc.connect(); 
    return huc.getResponseCode(); 
} 

またはこれを試してみてください。http://www.java-tips.org/java-se-tips/java.net/check-if-a-page-exists-2.html

+0

..あなたのために働いている一つの解決策のおかげで教えてください。私はメソッドの正確な文字列を知っているので、コードを簡単にすることはできますか?パラメータは分かりません(私はC#ではあまりうまくいきません)。 – xyz

+0

Javaソリューションをお寄せいただきありがとうございます:) – xyz