Netbeans 5.5 WebService Client - How do I pass a parameter to the service?

I'm using Netbeans 5.5 and have generated a webservice client (JAX-WS 2.0) off of the existing WSDL. The webservice requires me to pass it some information. Per the generated code, it is expecting an EncryptedData object. The problem is, I have no idea what the content of this data object should be as it pertains to an anonymous complex type. The code generated for this class is listed below. Any ideas? By the way, I know what SOAP should be generated... I just don't know how to stick the soap information into this EncryptedData object. Thanks!

/**

*

Java class for anonymous complex type.

*

*

The following schema fragment specifies the expected content contained within this class.

*

* <pre>

* <complexType>

*<complexContent>

*<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*<sequence>

* <any/>

*</sequence>

*</restriction>

*</complexContent>

* </complexType>

* </pre>

*

*

*/

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

"content"

})

public static class EncryptedData {

@XmlMixed

@XmlAnyElement(lax = true)

protected List<Object> content;

/**

* Gets the value of the content property.

*

*

* This accessor method returns a reference to the live list,

* not a snapshot. Therefore any modification you make to the

* returned list will be present inside the JAXB object.

* This is why there is not a <CODE>set</CODE> method for the content property.

*

*

* For example, to add a new item, do as follows:

* <pre>

*getContent().add(newItem);

* </pre>

*

*

*

* Objects of the following type(s) are allowed in the list

* {@link Object }

* {@link String }

*

*

*/

public List<Object> getContent() {

if (content == null) {

content = new ArrayList<Object>();

}

return this.content;

}

}

Message was edited by:

Tosa_Developer

[2282 byte] By [Tosa_Developera] at [2007-11-27 0:54:17]
# 1
Just create and insance of the EncryptedData object, add any data via its methods, and then pass it as a parameter to one of the methods on the port. JAX-WS will do the work to turn it into SOAP.
dkohlerta at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

hello,

I have done exactly as you have mentioned but I am facing prob passing String or XML data in the newItem variable:

If I run the below code in jsp >

EncryptedData eD=new EncryptedData ();

String newItem="test";

eD.getContent().add(newItem);

port.webMethod(eD);

I encouter the following error at runtime:

javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation]

Pls help me pass either XML or String value to the webservice inside this encrpteddata.

Thanx 4 ton 4 ur time and help.

Lmassa at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
I am using Jax-WS2.0 and netbeans5.5
Lmassa at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
HelloMy friend i am facing the same problem as yours. I am using JBuilder and I am trying to call a webservice from a MIDLET in J2ME. If you find any solution from elsewehere please tell me as well. :-(
Mujia at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Sure muji I ll pass on the soln if i find one. I have been struggling on this prob for almost a week now. Incase u get a soln pl pass the same 2 me too
Lmassa at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Hi!

Try passing in a DOM Element instead of a String, ie something like

Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

Element elm = dom.createElement( "test" );

elm.appendChild( dom.createTextNode( "test content" ) );

eD.getContent().add(elm);

Hope this helps!

/Ole

eviware.com

olemata at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7
This works. Thank u so much friend, u solved a very big prob of mine.
Lmassa at 2007-7-11 23:26:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...