Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebMethod returns null if there is no other parameter before the holder parameter #598

Open
Tomas-Kraus opened this issue Jun 2, 2022 · 0 comments

Comments

@Tomas-Kraus
Copy link
Member

Previously tracked via: https://bugs.openjdk.java.net/browse/JDK-8170462

To reproduce the issue:

  1. wsgen -cp . wstest.EchoImpl against the following java file:
    package wstest;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.Holder;
import java.rmi.RemoteException;
import javax.jws.soap.SOAPBinding;

@webservice
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class EchoImpl {
@webmethod
public String holderOperation(@WebParam(name="holder1", mode=WebParam.Mode.INOUT)Holder holder1,
@WebParam(name="holder2", mode=WebParam.Mode.INOUT)Holder holder2) throws RemoteException{
holder1.value += "1";
holder2.value += "2";
return "success";
}
}

  1. start the web service with the following java file:
    package wstest;

import javax.xml.ws.Endpoint;

public class EchoService {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/WebServices/echoimpl", new EchoImpl());
}
}

  1. generate the client:
    wsimport -keep -p wstest.server http://localhost:8080/WebServices/echoimpl?wsdl

  2. run the client test with the following java file:
    import java.rmi.;
    import javax.naming.
    ;
    import wstest.server.*;
    import javax.xml.ws.Holder;

public class EchoClient {
public static void main(String[] args) {
EchoImplService service = new EchoImplService();
EchoImpl port = service.getPort(EchoImpl.class);
Holder h1 = new Holder("1");
Holder h2 = new Holder("2");
String result = port.holderOperation(h1, h2);

    System.out.println(result); 
    System.out.println(h1.value); 
    System.out.println(h2.value); 
} 

}

Will get:
null
11
22

Note:

  1. Obviously some changes made the result better, now only the return value is null.
  2. If removing @SOAPBinding(style=SOAPBinding.Style.RPC) from EchoImpl java file or inserting a non-holder parameter at the first place in holderOperation method, it will have return value.

Source: javaee/metro-jax-ws#1224
Author: LanceAndersen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant