Passing class to WS

C

carmelo

Hi everybody,
I'm developing a client which sends data to a WebService. I'm trying
to do that without success.

Using the following code the WebService receives a "null" value, and
as response I get "Result = null".


- WebService

package dbws;

public class DBWS {
public String insert(MyClass myclass)
{
return myclass.getField();
}

}

- Client

package dbws_client;

public class Main {

public static void main(String[] args) {

try { // Call Web Service Operation

dbws.DBWS service = new dbws.DBWS();
dbws.DBWSPortType port =
service.getDBWSHttpSoap12Endpoint();
// initialize WS operation arguments here
dbws.xsd.MyClass myclass = new dbws.xsd.MyClass();

dbws.xsd.ObjectFactory of = new dbws.xsd.ObjectFactory();

myclass.setField(of.createMyClassField("my_value"));
//myclass.setField(new JAXBElement(null, String.class, new
String("my_value")));

// process result here
java.lang.String result = port.insertData(myclass);
System.out.println("Result = " + result);
} catch (Exception ex) {
// handle custom exceptions here
}

}

}


How can I do to pass a class correctly to the WebService?
Thank you very much for your help
 
C

carmelo

Hi everybody,
I'm developing a client which sends data to a WebService. I'm trying
to do that without success.

Using the following code the WebService receives a "null" value, and
as response I get "Result = null".

- WebService

package dbws;

public class DBWS {
    public String insert(MyClass myclass)
    {
        return myclass.getField();
    }

}

- Client

package dbws_client;

public class Main {

    public static void main(String[] args) {

        try { // Call Web Service Operation

            dbws.DBWS service = new dbws.DBWS();
            dbws.DBWSPortType port =
service.getDBWSHttpSoap12Endpoint();
            // initialize WS operation arguments here
            dbws.xsd.MyClass myclass = new dbws.xsd.MyClass();

            dbws.xsd.ObjectFactory of = new dbws.xsd.ObjectFactory();

            myclass.setField(of.createMyClassField("my_value"));
            //myclass.setField(new JAXBElement(null, String.class, new
String("my_value")));

            // process result here
            java.lang.String result = port.insertData(myclass);
            System.out.println("Result = " + result);
        } catch (Exception ex) {
            // handle custom exceptions here
        }

    }

}

How can I do to pass a class correctly to the WebService?
Thank you very much for your help

I solved the problem passing it as a simple string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top