2017-02-14 7 views
0

나는 WSO2의 웹 서비스에 대한 WSO2 클라이언트를 생성하기 위해 아래 명령을 사용하고는WSO2의 웹 서비스 널 포인터 예외

으로 wsimport -keep 내가 자바 1.8.0_112 사용하여이 클라이언트를 생성

https://svn.wso2.org/repos/wso2/people/asela/user-mgt/jaxws/RemoteUserStoreManagerService.wsdl을 -verbose. - 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> 

업데이트 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를 확인하십시오. –