views:

39

answers:

0

Hello,

I am trying to read the Type elements from a WSDL. I need to extract the types information to extract the elements from the returned SOAP object. I have been experimenting with several classes over the last couple of days with no progress. Here is my code,

// Identify Simple Web Service Site with some good Types
String endpoint = "http://ws.cdyne.com/WeatherWS/Weather.asmx"; 
String wsdlURI = endpoint + "?WSDL";
// Now build the reader
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader reader = wsdlFactory.newWSDLReader();
//Set features -- most are defaults but this is instructive
reader.setFeature("javax.wsdl.verbose",false);
reader.setFeature("javax.wsdl.importDocuments",true);
// Go read the WSDL from the URI
Definition definition = reader.readWSDL(null, wsdlURI);
// Extract the Types
Types types = definition.getTypes();
String strTypes = types.toString();
// Let's take a look
System.out.println(strTypes);

As you can see I am getting the WSDL from the URI. When I print out the strTypes I get,

SchemaExtensibilityElement ({http://www.w3.org/2001/XMLSchema}schema):
required=null
element=[s:schema: null]

The following is the WSDL showing only the defitions and types section,

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://ws.cdyne.com/WeatherWS/"  
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
targetNamespace="http://ws.cdyne.com/WeatherWS/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"&gt;
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://ws.cdyne.com/WeatherWS/"&gt;
      <s:element name="GetWeatherInformation">
        <s:complexType />
      </s:element>
      <s:element name="GetWeatherInformationResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetWeatherInformationResult" 
                  type="tns:ArrayOfWeatherDescription" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:complexType name="ArrayOfWeatherDescription">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="WeatherDescription" type="tns:WeatherDescription" />
    </s:sequence>
  </s:complexType>
  <s:complexType name="WeatherDescription">
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="WeatherID" type="s:short" />
      <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="PictureURL" type="s:string" />
    </s:sequence>
  </s:complexType>
  <s:element name="GetCityForecastByZIP">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="ZIP" type="s:string" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:element name="GetCityForecastByZIPResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="GetCityForecastByZIPResult" type="tns:ForecastReturn" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:complexType name="ForecastReturn">
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean" />
      <s:element minOccurs="0" maxOccurs="1" name="ResponseText" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="WeatherStationCity" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="ForecastResult" type="tns:ArrayOfForecast" />
    </s:sequence>
  </s:complexType>
  <s:complexType name="ArrayOfForecast">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="Forecast" nillable="true" type="tns:Forecast" />
    </s:sequence>
  </s:complexType>
  <s:complexType name="Forecast">
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Date" type="s:dateTime" />
      <s:element minOccurs="1" maxOccurs="1" name="WeatherID" type="s:short" />
      <s:element minOccurs="0" maxOccurs="1" name="Desciption" type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="Temperatures" type="tns:temp" />
      <s:element minOccurs="1" maxOccurs="1" name="ProbabilityOfPrecipiation" type="tns:POP" />
    </s:sequence>
  </s:complexType>
  <s:complexType name="temp">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="MorningLow" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="DaytimeHigh" type="s:string" />
    </s:sequence>
  </s:complexType>
  <s:complexType name="POP">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="Nighttime" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Daytime" type="s:string" />
    </s:sequence>
  </s:complexType>
  <s:element name="GetCityWeatherByZIP">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="ZIP" type="s:string" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:element name="GetCityWeatherByZIPResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="GetCityWeatherByZIPResult" type="tns:WeatherReturn" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:complexType name="WeatherReturn">
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean" />
      <s:element minOccurs="0" maxOccurs="1" name="ResponseText" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="WeatherStationCity" type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="WeatherID" type="s:short" />
      <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Temperature" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="RelativeHumidity" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Wind" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Pressure" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Visibility" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="WindChill" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Remarks" type="s:string" />
    </s:sequence>
  </s:complexType>
  <s:element name="ArrayOfWeatherDescription" nillable="true" type="tns:ArrayOfWeatherDescription" />
  <s:element name="ForecastReturn" nillable="true" type="tns:ForecastReturn" />
  <s:element name="WeatherReturn" type="tns:WeatherReturn" />
</s:schema>

I have tried DomBuilder and a couple of other methods but no luck so far. I have seen several posing asking the same question, however most of the methods don't seem to work. I am having no problem reading the messages, porttypes, bindings, and services. I just can't seem to get at the types corrrectly.

Update 07/29/10 -- I have started reading JWSDL (Java API's for WSDL ver. 1.2). The document describes a registration process for each exstensible element and attribute. This seems to be a lightweight API that allows you to access these type elements. The document is not very clear on how to access these elements -- at least to me! I will read it a couple of more times to see if brain osmosis will work. I think I am going in the right direction. Anyone have an example of using JWSDL and accessing the type elements?

Update 08/04/10 -- I still have not been able to exstract the types section with JWSDL. Has anybody ever used the Woden API? I just found it and I am going through the API. Seems to be written in 2008 so maybe a little more up to date. JWSDL seems to be written in 2006. Any help with extracting types from a WSDL using JWSDL or Woden would be very helpful.

Regards, Steve Mansfield