5

スタンドアロンの Java クラス (mainメソッドを含む) から jax ws Web サービスを呼び出そうとしています。SOAP UI でこれを試したところ、応答が返されました。

私のJavaコード: main()メソッド内:

GInformation getGMInfo = new GInformation();
GInformationResult getGMResult = new GInformationResult();

GKService GKProxy = getProxy();

//Set the Request
XMLGregorianCalendar xmlGreg = null;
getGMInfo.setRequestId("");
getGMInfo.setMessageDateTime(xmlGreg);

try {
    //Get the response
    getGMResult = GKProxy.getGInformation(getGMInfo);
    System.out.println("Address: "+getGMResult.getInfo());
} catch (OperationFaultException e) {
    e.printStackTrace();
} catch (SystemFaultException e) {
    e.printStackTrace();
} 

しかし、次のようなエラーで失敗しています:

org.apache.axis2.AxisFault: WSWS7130E: No Secure Sockets Layer (SSL) configuration is available for the https://mklip.verd.Gin/WS/v2.8 endpoint.

私はこれを非常に長い間修正しようとしてきましたが、気が狂う寸前です. 誰かが私がここで間違っていることを教えてもらえますか? スタンドアロンのJavaクラスからjax-wsを呼び出すことはまったく可能ですか、それともWebサーバーが必要ですか? ただし、このアプリケーションには Web サーバーがありません。

4

3 に答える 3

4

この問題を解決するには、さらに深く掘り下げる必要がありました。私が抱えていた問題は、信頼できる証明書の問題です。まず、サービスを呼び出すために必要な証明書 (cert1.cer、cert2.cer) を手に入れました。

次に、次の手順を使用して証明書をローカルに統合しました。

1. Place the below cry certificates in the path "C:\Program Files\IBM\SDP\jdk\jre\lib\security"

   cert1.cer, cert2.cer 

2. cacerts is the trusStore file. It's present in :
   C:/Program Files/IBM/SDP/jdk/jre/lib/security/cacerts

3. In command prompt perform the below execution
C:\Program Files\IBM\SDP\jdk\jre\lib\security>"C:\Program Files\IBM\SDP\jdk\jre\bin\keytool" -import -alias cert1 -file cert1.cer -keystore cacerts

4. If it asks keystore password, mention changeit, which is the default keystore password

Enter keystore password: changeit

Trust this certificate? [no]:  yes
Certificate was added to keystore

5. Peform the steps 3 and 4 for the second certificate(cert2.cer).

しかし、それだけでは十分ではありませんでした。javax.net.ssl次のようにプログラムで設定する必要がありました。

System.setProperty("javax.net.ssl.trustStore", "C:\\Program Files\\IBM\\SDP\\jdk\\jre\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStore", "C:\\Program Files\\IBM\\SDP\\jdk\\jre\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");

上記の数行のコードにより、WS 呼び出し中に と が SSL 呼び出し用に設定されているtrustStoreことが保証されます。keyStore

これは簡単に手に入れることができなかったので、ここで説明と回答を提供したので、同じ問題を抱えている人がいる場合は、問題を軽減するための参照としてそれを取ることができます. 乾杯!

于 2013-09-11T08:42:13.240 に答える
3

以下の行をプログラムの最初の行として挿入します。これで問題は解決します。System.setProperty("com.ibm.SSL.ConfigURL", "file:C:\IBM\WebSphere\AppServer\profiles\AppSrv01\properties\ssl.client.props");

于 2016-04-06T18:37:29.537 に答える
1

エンドポイント アドレスを Web サービス アドレスに設定してみましたか。私の場合、クライアント コードを含む WSDL ファイルから jar を生成しました。

私のテストケースの一例は

public static void main(String[] args){
          SecurityRefServiceLocator securityRefServiceLocator = new SecurityRefServiceLocator();
            securityRefServiceLocator.setSecurityrefPortEndpointAddress("http://xxxxx:13600/my_ss/webservice/refreshSecurity?wsdl");
            WebserviceClient webserviceClient = new WebserviceClient();
            webserviceClient.setSecurityRefServiceLocator(securityRefServiceLocator);
            System.out.println(webserviceClient.refreshSecurity(8798789l,"1114"));

}

}

WeberviceClient コード

public WebServiceReturnCode refreshSecurity(Long securityId, String productId) {

    try{
        SecurityRef securityRef = securityRefServiceLocator.getSecurityrefPort();

        SecurityServiceBindingStub  securityServiceBindingStub=
            (SecurityServiceBindingStub) securityRef;

        securityServiceBindingStub.setUsername("user");
        securityServiceBindingStub.setPassword("password");

        securityServiceBindingStub.setTimeout(timeout);

        SecurityServiceRequest parameter = new SecurityServiceRequest();

        parameter.setMessageId("MSG-" + securityId);
        parameter.setSecurityId(securityId.toString());
        SecurityServiceResponse refreshSecurity = securityRef.refreshSecurity(parameter);
        ResponseType msgResponse = refreshSecurity.getMsgResponse();
        //evaluate msg response and send E200; if fail
        if(msgResponse.equals(ResponseType.SUCCESS)){
            return WebServiceReturnCode.SUCCESS;
        }
        // Response was not favorable
        return "WSE200";

    }catch(Exception e){
        // Exception occurred. Mark this as technical failure to webservice call.
        return "WSE100";
    }finally{
}
}

public SecurityRefServiceLocator getSecurityRefServiceLocator() {
    return securityRefServiceLocator;
}

public void setSecurityRefServiceLocator(
        SecurityRefServiceLocator securityRefServiceLocator) {
    this.securityRefServiceLocator = securityRefServiceLocator;
}
于 2013-09-10T11:48:20.857 に答える