This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Web Services and the fly likes parameters type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "parameters type" Watch "parameters type" New topic

parameters type

Guadalupe Ortiz
Ranch Hand

Joined: Sep 12, 2003
Posts: 74
I think is a very simpler question:
When I check an WSDL file and I see the parameter of the operaton to invoke in a String, for example, i know that I have to invoke the operation with a parameter of the type String, but , when I have the next code in the WSDl file:

- <s:element name="getInfo">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CountryAbbrviation" type="s:string" />
- <wsdl:message name="getAirportInfo">
<wsdl: part name="parameters" element="tns:getInfo" />

What type of parameter should I use in the invocation?
Thanks very much for your answer

Doug Hoople

Joined: Dec 29, 2004
Posts: 11
Hi Guadalupe,

Why not try seeing what you get for output when you generate your client proxies and test apps from the WSDL file?

At first glance, I'd say declare it:

getInfo gi = new getInfo();
gi.CountryAbbrviation[0] = "UK";

and then call (assuming you've already loaded your proxy):


I haven't actually tried this, so I don't know for sure if it will work. What you'll have to fool around with is the representation of the string within the object. I'm not 100% about that. The XSD declaration makes it look like it should be an array of strings instead of just one string. To make it just one string, take out the min- and max-occurs.

Again, see if you can get your code generators to build you a client testapp.

Doug Hoople
Doug Hoople

Joined: Dec 29, 2004
Posts: 11
Hi Guadalupe,

I took my own advice, ran the stub generator and, boy, was I ever wrong. The data structure you were asking about was a garden-variety string, after all.

And you were right, it is pretty simple. Assuming that the method you're calling is getAirportInfo, then you'd simply pass a string for the getInfo parameter (the element that defines CountryAbbrviation).

The stub's interface method declaration would look like this:

public String getAirportInfo(String CountryAbbrviation);

And you'd call it with the following (again assuming you'd already loaded up your proxy reference):

String airportInfo;
String countryCode = "UK";
airportInfo = proxy.getAirportInfo(countryCode);

Hope this helps. Sorry to have misled you.

Doug Hoople
Guadalupe Ortiz
Ranch Hand

Joined: Sep 12, 2003
Posts: 74
Thank-you very much for your answer. i tried it and it works very fine. now I have a very similar doubt. If a find an wsdl where one operation use a complex typoe as for example:
- <xsd:complexType name="WeatherSummary">
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="location" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="wind" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="sky" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="temp" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="humidity" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="pressure" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="visibility" nillable="true" type="xsd:string" />


How should I define my type for making the invocation. i tried an ArraList but it did not work.
Thanks again for your help, looking forward to your new answer,

Doug Hoople

Joined: Dec 29, 2004
Posts: 11
Hi Guadalupe,

In this case, you DO have to use the object creation syntax and use the complextype name, "WeatherSummary" for this.

For example,

WeatherSummary ws = new WeatherSummary();
ws.location = "NY";
ws.wind = "25"; = "clear";
ws.temp = "56";
ws.humidity = "65";
ws.pressure = "1011";
ws.visibility = "2miles";

Then, you'd invoke a method like setWeatherInfo as follows:


If you're receiving this as a return type, you'd declare and use as follows:

WeatherSummary ws;
ws = getWeatherInfo(today); // returns a single weather summary

Or, if it's an array of user-defined types

WeatherSummary [] ws;
ws = getWeatherInfo(today,5); // returns array of 5 summaries

Doug Hoople
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: parameters type
It's not a secret anymore!