cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Lowski (JIRA)" <>
Subject [jira] [Created] (CXF-5588) IllegalArgumentException when invoking web service
Date Mon, 03 Mar 2014 10:54:22 GMT
Robert Lowski created CXF-5588:

             Summary: IllegalArgumentException when invoking web service
                 Key: CXF-5588
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
    Affects Versions: 3.0.0-milestone2
         Environment: Netbeans 7.3, Glassfish 3.1.2
            Reporter: Robert Lowski

Hello Guys,
i have a problem, invoking webservice with dynamic client from JaxWsDynamicClientFactory.
at first a little code-example:

Entity for web service shoud be an instance of class Person:

public class Person {
private String name;
//public setter and getter for name

Web service:

@WebService(serviceName = "NewWebService")
public class NewWebService {

 @WebMethod(operationName = "getPerson")
    public Person getPerson(@WebParam(name = "person") Person person) {
        return person;

Ok now I'm trying to invoke the web service method getPerson:

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
            ClassLoader classLoader = DynamicWebserviceClient.class.getClassLoader();
            Client client = dcf.createClient(wsdlFileName);

//get instance of generated input-class
Object person = Thread.currentThread().getContextClassLoader().loadClass("").newInstance();
//initialize instance
 Method m = person.getClass().getMethod("setName", String.class);
            m.invoke(person, "Robert");

Up to this point everything works well. So now im trying to invoke the web service method.
Usually, yout would think, that you have to give the person instance as parameter for the
web service mehod like:
client.invoke("getPerson", person);

But when i do this, I get a IllegalArgumentException  because the invoke method is inspecting
an instance from So I'm creating an instance of this class
Object getPerson = Thread.currentThread().getContextClassLoader().loadClass("").newInstance();
and do:
Field field = getPerson.getClass().getDeclaredField("person");
//i know, that this isn't the smatest way but it's ok for this example
            field.set(getPerson, person);

Now i have an initialized instance of and can invoke the
web service method with the client like:
client.invoke("getPerson", getPerson);

The web service is invoked but the input parameter is null. I think, it's because the method
expects an input of type peron and not getPerson.

Am i'm doing something wrong?

This message was sent by Atlassian JIRA

View raw message