Preface
In the previous three articles,
[One of the AXIS2 and Eclipse Integration Development Web Service series] generates a Web service Client (translates WSDL into Java code) [Axis2 and Eclipse Integrated Development Web Service series of the second] Top-down way, through the WSDL reverse generation service side [Axis2 and Eclipse Integrated Development Web Service series bis] Top-down mode, reverse generation of service end via WSDL (cont.)
Describes how to use AXIS2 with Eclipse to develop a web Service. An integer value is returned in the third article and returns a value.
The resulting Xxsoapimpl,java code is as follows:
Directly like this, there is no problem.
However, if you return multiple values, the resulting code is similar:
The return value is implemented by StringHolder this class.
However, this value cannot be obtained by the discovery of client-side calls.
First, give the solution to the problem: set the name of Request and Response in elements to uppercase.
1. When the name of Request and Response in elements is set to lowercase, the return value is StringHolder implemented
2. When the name of Request and Response in elements is set to lowercase, the return value produces a new class implementation
Here is a practical example to look at this problem.
The example in this article is a Web service for weather forecasts.
Input: City
Output: ReturnCode, returnmsg
An example
1. First create a WSDL with the name weatherforecastservice.wsdl
The results you see in Design view are as follows:
2. Then generate the Web service
Post-generated service-side code structure:
3. The contents of the generated DEPLOY.WSDD are as follows
The server side, implemented in this way, is called to find that the return value cannot be obtained.
Next, modify the configuration and change the name to uppercase.
How to change?
1. Click on the section below
2. Click again
3. Next, change the name, mainly to uppercase
In addition to modifying the name, you can also add a new type in the Types area,
The added type can be used in the following ways:
After the modification is complete, re-generate the new code:
Impl,java file
The resulting DEPLOY.WSDD
The problem basically solved
the resulting WSDL
Paste the contents of the most general generated WSDL:
<?xml version= "1.0" encoding= "UTF-8" standalone= "no"? ><wsdl:definitions xmlns:soap= "/http/ schemas.xmlsoap.org/wsdl/soap/"xmlns:tns=" http://www.oscar999.com/WeatherForecastService/"xmlns:wsdl="/HTTP/ schemas.xmlsoap.org/wsdl/"xmlns:xsd=" Http://www.w3.org/2001/XMLSchema "name=" Weatherforecastservice " Targetnamespace= "http://www.oscar999.com/WeatherForecastService/" > <wsdl:types> <xsd:schema Targetnamespace= "http://www.oscar999.com/WeatherForecastService/" > <xsd:complextype name= "Weatherresponse" > <xsd:sequence> <xsd:element name= "ReturnCode" type= "xsd:string" ></xsd:element> <x Sd:element name= "returnmsg" type= "xsd:string" ></xsd:element> </xsd:sequence> </xsd:complextype > <xsd:element name= "getweatherrequest" > <xsd:complexType> <xsd:sequence> <xsd:element maxoccurs= "1" minoccurs= "1" name= "City" type= "xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name= "getweat Herresponse "type=" Tns:weatherresponse "> </xsd:element> </xsd:schema> </wsdl:types> <wsdl:message name= "Getweatherrequest" > <wsdl:part element= "tns:getweatherrequest" name= "parameters"/> </wsdl:message> <wsdl:message name= "Getweatherresponse" > <wsdl:part element= "tns:getweatherresponse "name=" parameters "/> </wsdl:message> <wsdl:porttype name=" Weatherforecastservice "> <wsdl:o Peration name= "GetWeather" > <wsdl:input message= "tns:getweatherrequest"/> <wsdl:output message= "TNS: Getweatherresponse "/> </wsdl:operation> </wsdl:portType> <wsdl:binding name=" Weatherforecastservicesoap "type=" Tns:weatherforecastservice "> <soap:binding style=" document "Transport=" Http://schemas.xmlsoap.org/soap/http "/> <wsdl:operation name= "GetWeather" > <soap:operation soapaction= "getWeather" style= "document"/> <wsdl:input> < ; Soap:body use= "literal"/> </wsdl:input> <wsdl:output> <soap:body use= "literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name= "Weatherforecastservice" & Gt <wsdl:port binding= "Tns:weatherforecastservicesoap" name= "Weatherforecastservicesoap" > <soap:address location= "Http://www.oscar999.com/WeatherForecastService"/> </wsdl:port> </wsdl:service></wsdl :d efinitions>
[Axis2 and Eclipse Integrated Development Web Service Series III] service-side return value