File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "parameters type" Watch "parameters type" New topic
Author

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" />
</s:sequence>
</s:complexType>
</s:element>
[...]
- <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


Guadalupe
Doug Hoople
Greenhorn

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):

proxy.myMethod(gi);

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
MCSD.NET, MCDBA, MCSE, MCT, SCJP1.4
Doug Hoople
Greenhorn

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.

Thanks.
Doug Hoople
MCSD.NET, MCDBA, MCSE, MCT, SCJP1.4
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" />
</xsd:sequence>
</xsd:complexType>

(http://live.capescience.com/wsdl/AirportWeather.wsdl)

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,

Guadalupe
Doug Hoople
Greenhorn

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";
ws.sky = "clear";
ws.temp = "56";
ws.humidity = "65";
ws.pressure = "1011";
ws.visibility = "2miles";

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

setWeatherInfo(ws);

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

Thanks.
Doug Hoople
MCSD.NET, MCDBA, MCSE, MCT, SCJP1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: parameters type
 
Similar Threads
Problem with generated types
Empty target namespace with axis1.2
Found unknown simple type: javax.xml.soap.SOAPElement
Getting null value as response from .net webservice when calling from java client
parameters type