Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
J2ee|php5|web|web Service | program | Access Interpretation WSDL
We have successfully invoked the Weather service, but have not seen its WSDL document yet. The details in the WSDL are much more public than the soapclient. How do we know what to put in the StartDate parameter? What do we expect to actually get from the returned data? To answer these questions, you must analyze the WSDL more deeply.
You can download the WSDL for the Weather Forecast application from the download section. If you use a different Web service, just open the appropriate WSDL document in the browser.
The WSDL for the getforecast operation is:
<wsdl:operation name= "Getforecast"
<wsdl:input message= "Intf:getforecastrequest" name= "Getforecastrequest"
<wsdl:output message= "Intf:getforecastresponse" name= "Getforecastresponse"
The getforecastrequest message is defined as:
<wsdl:message name= "Getforecastrequest"
<wsdl:part element= "Intf:getforecast" name= "parameters"
And the GETFORECAST structure is defined as:
<element name= "Getforecast"
<element name= "StartDate" nillable= "true" type= "Xsd:datetime"/>
<element name= "Days" type= "Xsd:int"
So we know that the function requires two parameters, Xsd:datetime type of StartDate and integer type days. This exactly matches the Soapclient::_gettypes function we know, but now we also know that StartDate can be empty (nillable). There is no doubt that if we simplify the input parameters, the function will look like the following:
If you explicitly specify today's date, the result will be exactly the same as the specified.
What if you want to make other start dates? XML schemas define dateTime as a basic type, formatted according to the ISO 8601 standard, such as "2004-12-01t00:00:00". Assuming you want to know the weather forecast after three days, you can use the built-in function strtotime ("+3 Day") to get the date you want, the same function as the time () function, which returns the standard UNIX-formatted datetime, which is an integer that represents the number of seconds from the start of the year to the present We know that the XML Schema requirement date is encoded in an ISO 8601 format with a string field, so the timeToIso8601 function is written in the sample client to convert the integer date to the format defined by the SOAP encoding. But we were surprised to find that we didn't really need to do that, Ext/soap very cleverly converted the integer date to the Required String field format. Whether you pass an integer or a preformatted string, it doesn't matter, and the final delivery of the SOAP message is the same.
What about the dates in the response? On the return trip, Ext/soap obtained the DateTime field from the SOAP response, but did not make any format conversions. We want it to return an integer that represents the number of seconds from the year to now, but actually gets the string formatted according to ISO 8601. We then use the Strtotime function to convert it to an integer and then use strftime to format the integer so that it can be represented.
The Weather Service provides forecasts by date, but it ignores the time component in DateTime coding. So we have not considered this adjustment, and if you request weather forecasts from services running in different time zones, you may have to do so. If you want to learn more about time zone conversions, see the articles in resources that describe the ISO 8601 standard.
Now go back to the response format. The inconsistency of Getforecast return data was mentioned in the previous section. The WSDL description tells us that Getforecast returns a Getforecastresponse object that getforecastresponse can contain infinitely many lists of complex types called Weather:
<complextype name= "Weather"
<element name= "condition" nillable= "true" type= "xsd:string"/>
<element name= "Date" nillable= "true" type= "Xsd:datetime"/>
<element name= "Winddirection" nillable= "true" type= "xsd:string"/>
<element name= "windspeed" type= "Xsd:int"
<element name= "TemperatureCelsius" type= "Xsd:int"
<element name= "DBFlag" type= "Xsd:boolean"
The WSDL does not allow for a special case of the Unit Prime group. Unfortunately, when the response contains only one Weather object, Ext/soap does not consider the <sequence> label applied to Getforecastresponse in the WSDL, because this behavior creates unnecessary complexity in the client code.
Finally, the WSDL document also tells the SOAP client where to find the service from somewhere on the network:
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.