2017-02-14 14 views
0

私はJAVA 1.8.0_112を使用して、このクライアントを生成WSO2のWebサービスWSO2のWebサービスnullポインタ例外

wsimportの-keep -verbose https://svn.wso2.org/repos/wso2/people/asela/user-mgt/jaxws/RemoteUserStoreManagerService.wsdl

ためWSO2クライアントを生成するために与えられたコマンドの下に使用しています。 5.2.0バージョン - 私はWSO2アイデンティティサーバーを使用しています

Exception in thread "main" java.lang.NullPointerException 
    at com.sun.xml.internal.ws.model.JavaMethodImpl.freeze(JavaMethodImpl.java:379) 
    at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.freeze(AbstractSEIModelImpl.java:105) 
    at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:320) 
    at com.sun.xml.internal.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:85) 
    at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:59) 
    at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:43) 
    at com.sun.xml.internal.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:105) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:875) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:892) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:855) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:435) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:404) 
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:386) 
    at javax.xml.ws.Service.getPort(Service.java:119) 
    at org.wso2.carbon.um.ws.service.RemoteUserStoreManagerService.getRemoteUserStoreManagerServiceHttpSoap11Endpoint(RemoteUserStoreManagerService.java:72) 
    at org.wso2.carbon.test.TestUserLogin.main(TestUserLogin.java:15) 

:私は、生成されたメソッドコンストラクタ(URLのURL)を使用して、WSDLの場所を指定することで、クライアントを起動しようとしたとき、私は例外の下に取得しています。 ITはJava 1.8.0_112でも実行されています。クライアントを起動するために私のコードがある -

package org.wso2.carbon.test; 

import java.net.MalformedURLException; 
import java.net.URL; 

import org.wso2.carbon.um.ws.service.RemoteUserStoreManagerService; 
import org.wso2.carbon.um.ws.service.RemoteUserStoreManagerServicePortType; 
import org.wso2.carbon.um.ws.service.RemoteUserStoreManagerServiceUserStoreException_Exception; 

public class TestUserLogin { 
    public static void main(String args[]) throws MalformedURLException, RemoteUserStoreManagerServiceUserStoreException_Exception { 
     RemoteUserStoreManagerService rus = 
       new RemoteUserStoreManagerService(new URL("https://ril15066yjb152:9443/services/RemoteUserStoreManagerService?wsdl")); 

     RemoteUserStoreManagerServicePortType rusm = rus.getRemoteUserStoreManagerServiceHttpSoap11Endpoint(); 

     System.out.println(rusm.authenticate("admin", "admin")); 
    } 

} 

マイRemoteUserStoreManagerServiceクラスがある -

package org.wso2.carbon.um.ws.service; 

import java.net.MalformedURLException; 
import java.net.URL; 
import javax.xml.namespace.QName; 
import javax.xml.ws.Service; 
import javax.xml.ws.WebEndpoint; 
import javax.xml.ws.WebServiceClient; 
import javax.xml.ws.WebServiceException; 
import javax.xml.ws.WebServiceFeature; 


/** 
* This class was generated by the JAX-WS RI. 
* JAX-WS RI 2.2.9-b130926.1035 
* Generated source version: 2.2 
* 
*/ 
@WebServiceClient(name = "RemoteUserStoreManagerService", targetNamespace = "http://service.ws.um.carbon.wso2.org", wsdlLocation = "https://svn.wso2.org/repos/wso2/people/asela/user-mgt/jaxws/RemoteUserStoreManagerService.wsdl") 
public class RemoteUserStoreManagerService 
    extends Service 
{ 

    private final static URL REMOTEUSERSTOREMANAGERSERVICE_WSDL_LOCATION; 
    private final static WebServiceException REMOTEUSERSTOREMANAGERSERVICE_EXCEPTION; 
    private final static QName REMOTEUSERSTOREMANAGERSERVICE_QNAME = new QName("http://service.ws.um.carbon.wso2.org", "RemoteUserStoreManagerService"); 

    static { 
     URL url = null; 
     WebServiceException e = null; 
     try { 
      url = new URL("https://svn.wso2.org/repos/wso2/people/asela/user-mgt/jaxws/RemoteUserStoreManagerService.wsdl"); 
     } catch (MalformedURLException ex) { 
      e = new WebServiceException(ex); 
     } 
     REMOTEUSERSTOREMANAGERSERVICE_WSDL_LOCATION = url; 
     REMOTEUSERSTOREMANAGERSERVICE_EXCEPTION = e; 
    } 

    public RemoteUserStoreManagerService() { 
     super(__getWsdlLocation(), REMOTEUSERSTOREMANAGERSERVICE_QNAME); 
    } 

    public RemoteUserStoreManagerService(WebServiceFeature... features) { 
     super(__getWsdlLocation(), REMOTEUSERSTOREMANAGERSERVICE_QNAME, features); 
    } 

    public RemoteUserStoreManagerService(URL wsdlLocation) { 
     super(wsdlLocation, REMOTEUSERSTOREMANAGERSERVICE_QNAME); 
    } 

    public RemoteUserStoreManagerService(URL wsdlLocation, WebServiceFeature... features) { 
     super(wsdlLocation, REMOTEUSERSTOREMANAGERSERVICE_QNAME, features); 
    } 

    public RemoteUserStoreManagerService(URL wsdlLocation, QName serviceName) { 
     super(wsdlLocation, serviceName); 
    } 

    public RemoteUserStoreManagerService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { 
     super(wsdlLocation, serviceName, features); 
    } 

    /** 
    * 
    * @return 
    *  returns RemoteUserStoreManagerServicePortType 
    */ 
    @WebEndpoint(name = "RemoteUserStoreManagerServiceHttpSoap11Endpoint") 
    public RemoteUserStoreManagerServicePortType getRemoteUserStoreManagerServiceHttpSoap11Endpoint() { 
     return super.getPort(new QName("http://service.ws.um.carbon.wso2.org", "RemoteUserStoreManagerServiceHttpsSoap11Endpoint"), RemoteUserStoreManagerServicePortType.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns RemoteUserStoreManagerServicePortType 
    */ 
    @WebEndpoint(name = "RemoteUserStoreManagerServiceHttpSoap11Endpoint") 
    public RemoteUserStoreManagerServicePortType getRemoteUserStoreManagerServiceHttpSoap11Endpoint(WebServiceFeature... features) { 
     return super.getPort(new QName("http://service.ws.um.carbon.wso2.org", "RemoteUserStoreManagerServiceHttpSoap11Endpoint"), RemoteUserStoreManagerServicePortType.class, features); 
    } 

    private static URL __getWsdlLocation() { 
     if (REMOTEUSERSTOREMANAGERSERVICE_EXCEPTION!= null) { 
      throw REMOTEUSERSTOREMANAGERSERVICE_EXCEPTION; 
     } 
     return REMOTEUSERSTOREMANAGERSERVICE_WSDL_LOCATION; 
    } 

} 

答えて

3

NPEを削除するには、このコードを試してみてください。

RemoteUserStoreManagerService rus = 
      new RemoteUserStoreManagerService(); 

    RemoteUserStoreManagerServicePortType rusm = rus.getRemoteUserStoreManagerServiceHttpsSoap11Endpoint(); 
    ((BindingProvider) rusm).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint); 
    org.apache.cxf.endpoint.Client client = ClientProxy 
      .getClient(rusm); 

    HTTPConduit http = (HTTPConduit) client.getConduit(); 
    http.getAuthorization().setUserName("admin"); 
    http.getAuthorization().setPassword("admin"); 

    System.out.println("User authenticate? " + rusm.authenticate("admin", "admin")); 
    List<String> listUsers = rusm.listUsers("*", 100); 
    for (String user : listUsers) { 
     System.out.println("User: " + user); 

    } 

UPDATE 1: をも更新する必要がありますサービスセクションのこのポートを持つWSDL:

<wsdl:port name="RemoteUserStoreManagerServiceHttpsSoap11Endpoint" binding="ns:RemoteUserStoreManagerServiceSoap11Binding"> 
     <soap:address location="https://localhost:9443/services/RemoteUserStoreManagerService.RemoteUserStoreManagerServiceHttpsSoap11Endpoint/"/> 
    </wsdl:port> 

UPDATE 2:ユーザー認証を検証する前にhttp基本認証を追加しました。上記のコードを確認してください。

私のクライアントの応答:

User authenticate? true 
User: WSO2.ORG/admin 
User: WSO2.ORG/isildurmac 
+0

こんにちはホルヘ、ご返信いただきありがとうございます。私はコードを与えてみましたが、私は以下の例外を受けています。あなたのコードでは、メソッド名** getRemoteUserStoreManagerServiceHttpsSoap11Endpoint **を** getRemoteUserStoreManagerServiceHttpSoap11Endpoint **に変更しました。これはRemoteUserStoreManagerServiceクラスにこのメソッドしかないためです。 スレッド "main"の例外com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException:2つのInaccessibleWSDLExceptionのカウント。 java.net.ConnectException:接続が拒否されました:内のすべての管理サービス...私の更新をチェックして、CXFクライアントを再生成する – Abhishek

+0

org.wso2.carbon.test.TestUserLogin.main(TestUserLogin.java:25)で を接続wso2はhttpではなくhttpsを使用します。 –

+0

私の更新を確認してください2. –