Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a value to a javax.xml.ws.Holder?

we are currently having problems with a JAX-WS implementation, particulary in getting a value returned by the service, which in our case is always null, although we give it a value.

Some code before more explanations of our problem :

Here is the signature of our operation :

@WebMethod(action = "urn:genererEdition")
public void genererEdition(
    @WebParam(name = "requeteEdition", targetNamespace = "http://creditcgi.com/serviceeditique", partName = "requete")
    RequeteEdition requete,
    @WebParam(name = "reponseEdition", targetNamespace = "http://creditcgi.com/serviceeditique", mode = WebParam.Mode.OUT, partName = "reponse")
    Holder<ReponseEdition> reponse,
    @WebParam(name = "documentProduit", targetNamespace = "", mode = WebParam.Mode.OUT, partName = "documentProduit")
    Holder<byte[]> documentProduit);

Here is our web service test case :

@Test
public void testCallGenererEdition() {
    RequeteEdition requete = new RequeteEdition();

    Holder<ReponseEdition> reponseHolder = new Holder<ReponseEdition>(new ReponseEdition());
    Holder<byte[]> documentHolder = new Holder<byte[]>(new byte[512]);

    editique.genererEdition(requete, reponseHolder, documentHolder);

    Assert.assertNotNull(reponseHolder.value);
    Assert.assertNotNull(reponseHolder.value.getCodeRetour());
}

And finally, our WS implementation :

@Override
public void genererEdition(RequeteEdition requete,
        Holder<ReponseEdition> reponse, Holder<byte[]> documentProduit) {

    // if we do no instanciate ReponseEdition, we got a Null Pointer Exception
    reponse.value = new ReponseEdition();

    reponse.value.setCodeRetour("OK");
}

As you can see with the test, we are always getting null. What do we do wrong for always having a null object returned in the reponse Holder ?

Thank you in advance.

like image 976
ipingu Avatar asked Oct 28 '25 16:10

ipingu


1 Answers

It will solve your problem of getting NULL values in response.

....genererEdition(....){ ReponseEdition re = new ReponseEdition(); reponse.value = re; }

like image 74
nilsmart Avatar answered Oct 30 '25 06:10

nilsmart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!