This discussion is archived
5 Replies Latest reply: Aug 16, 2011 10:03 AM by 452071 RSS

Error in ADF Web Service Connection

491466 Newbie
Currently Being Moderated
Hello everyone.
I have the following problem.
Create a "Web Services Proxy" to consume a Web Services outside the application.
Web services require authentication and create a Web ADF Services Connection to authenticate, but when you programmatically use the ADF Web Service Connection I get the following error:

java.lang.NullPointerException
     at java.lang.Class.isAssignableFrom(Native Method)
     at oracle.j2ee.ws.common.jaxws.runtime.GenericJavaType.create(GenericJavaType.java:97)
     at oracle.j2ee.ws.common.jaxws.runtime.GenericJavaType.create(GenericJavaType.java:118)
     at oracle.j2ee.ws.common.jaxws.runtime.OperationMappingModeler.processParameters(OperationMappingModeler.java:268)
     at oracle.j2ee.ws.common.jaxws.runtime.OperationMappingModeler.processMethod(OperationMappingModeler.java:155)
     at oracle.j2ee.ws.common.jaxws.runtime.ServiceEndpointRuntimeModeler.buildRuntimeModel(ServiceEndpointRuntimeModeler.java:114)
     at oracle.j2ee.ws.client.jaxws.WsClientProxyFactory.getRuntimeMetadata(WsClientProxyFactory.java:69)
     at oracle.j2ee.ws.client.jaxws.WsClientProxyFactory.createProxy(WsClientProxyFactory.java:126)
     at oracle.j2ee.ws.client.jaxws.WsClientProxyFactory.createProxy(WsClientProxyFactory.java:106)
     at oracle.j2ee.ws.common.jaxws.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:219)
     at oracle.j2ee.ws.common.jaxws.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:249)
     at oracle.adf.model.connection.webservice.impl.WebServiceConnectionImpl.getJaxWSPort(WebServiceConnectionImpl.java:399)
     at edu.esade.portal.wsclient.wordpress.WordPressCliente.getDatosBlogsBndQSService(WordPressCliente.java:62)
     at edu.esade.portal.wsclient.wordpress.WordPressCliente.getDatosBlogsPortClient(WordPressCliente.java:86)
     at edu.esade.portal.wsclient.wordpress.WordPressCliente.getBlogs(WordPressCliente.java:105)
     at edu.esade.portal.wsclient.wordpress.WordPressCliente.main(WordPressCliente.java:167)

The code I use to get the connection is:

private DatosBlogsBndQSService getDatosBlogsBndQSService () {
Context ctx;
try {
ctx = ADFContext.getCurrent().getConnectionsContext();

WebServiceConnection wsc = (WebServiceConnection) ctx.lookup("DatosBlogsBndQSService");
System.out.println("wsc:"+wsc.toString());
DatosBlogsBndQSService proxy = wsc.getJaxWSPort(DatosBlogsBndQSService.class); // line 62
return proxy;
} catch (NamingException e) {
e.printStackTrace();
return null;
}

Finalmente la configuración del recurso es:

<Reference name="DatosBlogsBndQSService" className="oracle.adf.model.connection.webservice.impl.WebServiceConnectionImpl" credentialStoreKey="DatosBlogsBndQSService" xmlns="">
<Factory className="oracle.adf.model.connection.webservice.api.WebServiceConnectionFactory"/>
<RefAddresses>
<XmlRefAddr addrType="WebServiceConnection">
<Contents>
<wsconnection description="URL-XXX" service="{URL-XXX}DatosBlogsBndQSService">
<model name="{URL-XXX}DatosBlogsBndQSService" xmlns="http://oracle.com/ws/model">
<service name="{URL-XXX}DatosBlogsBndQSService">
<port name="DatosBlogsBndQSPort" binding="{URL-XXX}DatosBlogsBnd">
<soap username="transportUserName" password="transportPassword" addressUrl="URL-XXX" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
<operation name="consultarPosts">
<soap soapAction="URL-XXX" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
<output name=""/>
<input name=""/>
</operation>
<operation name="listarBlogs">
<soap soapAction="URL-XXX" xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>
<output name=""/>
<input name=""/>
</operation>
</port>
</service>
</model>
</wsconnection>
</Contents>
</XmlRefAddr>
<SecureRefAddr addrType="transportPassword"/>
<SecureRefAddr addrType="transportUserName"/>
</RefAddresses>
</Reference>
}

When the Web Service did not require authentication to work without problem, the error arises when you need to login and use the "ADF Web Services Connection", is there some other way to log in using the Web Service proxy client directly?

Any help is welcome.

Regards.
Marcelo
  • 1. Re: Error in ADF Web Service Connection
    Shay Shmeltzer Employee ACE
    Currently Being Moderated
    When you define a Web service data control one of the steps allows you to specify a user/password to access the service - did you fill out those?
    For a stand alone proxy class this might help: http://kingsfleet.blogspot.com/2009/01/security-policy-worked-example.html
  • 2. Re: Error in ADF Web Service Connection
    491466 Newbie
    Currently Being Moderated
    Hi Shay.

    I not use Web service data control, I use only Web Service proxy and the client class for populate data to view object programmatically.

    However, in a test class do I have this:


    /**
    */
    public class WordPressCliente {
    private final static Logger logger = Logger.getLogger(WordPressCliente.class);


    public WordPressCliente() {
    super();
    }

    private DatosBlogsBndQSService getDatosBlogsBndQSService () {
    Context ctx;
    try {
    ctx = ADFContext.getCurrent().getConnectionsContext();

    WebServiceConnection wsc = (WebServiceConnection) ctx.lookup("DatosBlogsBndQSService");
    System.out.println("wsc:"+wsc.toString());
    DatosBlogsBndQSService proxy = wsc.getJaxWSPort(DatosBlogsBndQSService.class);
    return proxy;
    } catch (NamingException e) {
    e.printStackTrace();
    return null;
    }
    }

    private DatosBlogsPT getDatosBlogsPortClient() throws Exception {
    /*
    URL baseUrl = DatosBlogsBndQSService.class.getResource(".");
    URL url = new URL(baseUrl,ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress"));
    QName qName = new QName("http://esade.edu/soa/servicio/DatosBlogs/v01_00","DatosBlogsBndQSService");
    System.setProperty("http.username", "atsistemas");
    System.setProperty("http.password", "atsistemas2011");
    DatosBlogsBndQSService integracionWordpress = new DatosBlogsBndQSService(url,qName);
    DatosBlogsPT wordpressPT = integracionWordpress.getDatosBlogsBndQSPort();
    if (ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress.autenticacion").equals("true")) {
    System.out.println("hay que validar el WS");
    BindingProvider bp = (BindingProvider)wordpressPT;
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress.usuario"));
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress.clave"));
    }
    */
    DatosBlogsPT wordpressPT = getDatosBlogsBndQSService().getDatosBlogsBndQSPort();
    return wordpressPT;
    }

    private DatosItemsPT getDatosItemsPortClient() throws Exception {
    DatosItemsBndQSService datosItems = new DatosItemsBndQSService();
    DatosItemsPT itemsPT = datosItems.getDatosItemsBndQSPort();
    if (ArchivoUtil.getInstance().getPropiedad("ws.integracion.items.autenticacion").equals("true")) {
    BindingProvider bp = (BindingProvider)itemsPT;
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress.usuario"));
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, ArchivoUtil.getInstance().getPropiedad("ws.integracion.wordpress.clave"));
    }
    return itemsPT;
    }


    public List<Blog> getBlogs() throws Exception {
    List<Blog> lista = null;
    try {
    DatosBlogsPT cliente = getDatosBlogsPortClient();
    FiltroBlogs filtroBlog = new FiltroBlogs();
    ListarBlogsInput blogInput = new ListarBlogsInput();
    HeaderESADE header = new HeaderESADE();
    header.setUsernameESADE("");
    header.setParentSOAComponent("");
    blogInput.setFiltroBlogs(filtroBlog);
    lista = cliente.listarBlogs(blogInput,header).getBlogs().getBlog();
    } catch (ClientTransportException e) {
    logger.error(e.getStackTrace());
    e.printStackTrace();
    ADFUtils.showMessage(Constantes.TITULO_01, Constantes.MENSAJE_01);
    }
    return lista;
    }

    public List<Post> getPostsPorBlog(String idBlog) throws Exception {
    List<Post> lista = null;
    try {
    DatosBlogsPT cliente = getDatosBlogsPortClient();
    ConsultarPostsInput postInput = new ConsultarPostsInput();
    FiltroPosts filtroPost = new FiltroPosts();
    HeaderESADE header = new HeaderESADE();
    filtroPost.setBlogId(new Long(idBlog).longValue());
    filtroPost.setFechaInicio(FechaUtil.getFecha());
    filtroPost.setFechaFin(null);
    header.setUsernameESADE("");
    header.setParentSOAComponent("");

    lista = cliente.consultarPosts(postInput,header).getPosts().getPost();
    } catch (ClientTransportException e) {
    logger.error(e.getStackTrace());
    ADFUtils.showMessage(Constantes.TITULO_01, Constantes.MENSAJE_01);
    }
    return lista;
    }

    public static void main(String[] args) {
    WordPressCliente wordPressCliente = new WordPressCliente();
    try {
    Iterator i = wordPressCliente.getBlogs().iterator();
    while (i.hasNext()) {
    Blog blog = (Blog)i.next();
    logger.debug("Blog Id:" + blog.getId() + " url:" + blog.getUrl() + " nombre:" + blog.getNombre() + " publico:" + blog.isPublico() + " lang:" + blog.getLang());
    try {
    Iterator j = wordPressCliente.getPostsPorBlog(Long.toString(blog.getId())).iterator();

    while (j.hasNext()) {
    Post post = (Post)j.next();
    logger.debug(" Post Id:" + post.getId() + " autor:" + post.getAutor() + " titulo:" + post.getTitulo() + " size ambitos:" + post.getAmbitos().getAmbito().size() +
    " tags:" + post.getTags());
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }


    }
  • 3. Re: Error in ADF Web Service Connection
    452071 Journeyer
    Currently Being Moderated
    Hi Marcelo,

    Edwin B did a sample a couple of years ago, can you check it out and let us know if the implementation works for your case? http://biemond.blogspot.com/2009/04/jax-ws-web-service-proxy-client-and.html

    Thanks,

    Juan Camilo
  • 4. Re: Error in ADF Web Service Connection
    452071 Journeyer
    Currently Being Moderated
    Hi Marcelo,

    Edwin B did a sample a couple of years ago, can you check it out and let us know if the implementation works for your case? http://biemond.blogspot.com/2009/04/jax-ws-web-service-proxy-client-and.html

    Thanks,

    Juan Camilo
  • 5. Re: Error in ADF Web Service Connection
    452071 Journeyer
    Currently Being Moderated
    Hi Marcelo,

    Edwin B did a sample a couple of years ago, can you check it out and let us know if the implementation works for your case? http://biemond.blogspot.com/2009/04/jax-ws-web-service-proxy-client-and.html

    Thanks,

    Juan Camilo

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points