facebook

Questions on WSDl, complex datatypes and WS Client

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #261350 Reply

    Johan Kenens
    Member

    Hi,

    After going through the WS example, it was time for the real work. I took one of my classes and converted it to a web service. To my surprise I got this working in a couple of minutes “with the web services explorer”. Great! When I exported the WSDL to the workbench is noticed that it was not validated against the schema. I got 2 validation errors, one for my return type which is an ArrayList of a user defined type “StatistiekRecord” and one for the exception thrown by the web method (see bold in the WSDL).

    The Client throws the XFire exception:

    Exception in thread “main” org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Couldn’t instantiate class. com.brabo.tests.StatistiekRecord
    org.codehaus.xfire.fault.XFireFault: Couldn’t instantiate class. com.brabo.tests.StatistiekRecord

    …and I don’t have a clue on where to start looking.

    Any help appreciated

    Johan

    The WSDL
    ————
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <wsdl:definitions xmlns:ns1=”http://util.brabo&#8221; xmlns:ns2=”http://werkdruk.brabo&#8221; xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope&#8221; xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding&#8221; xmlns:tns=”http://loodsen.werkdruk.brabo&#8221; xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/&#8221; xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; targetNamespace=”http://loodsen.werkdruk.brabo”&gt;
    <wsdl:types>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://loodsen.werkdruk.brabo”&gt;
    <xsd:element name=”getWerkDruk”>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”avan” type=”xsd:dateTime”/>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”atot” type=”xsd:dateTime”/>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”awerkuren” nillable=”true” type=”xsd:float”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name=”getWerkDrukResponse”>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”out” nillable=”true” type=”ns1:ArrayOfStatistiekRecord”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name=”WerkDrukException” type=”ns2:WerkDrukException”/>
    </xsd:schema>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://util.brabo”&gt;
    <xsd:complexType name=”ArrayOfStatistiekRecord”>
    <xsd:sequence>
    <xsd:element maxOccurs=”unbounded” minOccurs=”0″ name=”StatistiekRecord” nillable=”true” type=”ns1:StatistiekRecord”/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name=”StatistiekRecord”>
    <xsd:sequence>
    <xsd:element minOccurs=”0″ name=”statistiek” nillable=”true” type=”xsd:string”/>
    <xsd:element minOccurs=”0″ name=”waarde” nillable=”true” type=”xsd:anyType”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://www.w3.org/2001/XMLSchema”/&gt;
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://werkdruk.brabo”&gt;
    <xsd:complexType name=”WerkDrukException”>
    <xsd:sequence>
    <xsd:element minOccurs=”0″ name=”message” nillable=”true” type=”xsd:string”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    </wsdl:types>
    <wsdl:message name=”getWerkDrukRequest”>
    <wsdl:part element=”tns:getWerkDruk” name=”parameters”/>
    </wsdl:message>
    <wsdl:message name=”getWerkDrukResponse”>
    <wsdl:part element=”tns:getWerkDrukResponse” name=”parameters”/>
    </wsdl:message>
    <wsdl:message name=”WerkDrukException”>
    <wsdl:part element=”tns:WerkDrukException” name=”WerkDrukException”/>
    </wsdl:message>
    <wsdl:portType name=”WerkDrukServicePortType”>
    <wsdl:operation name=”getWerkDruk”>
    <wsdl:input message=”tns:getWerkDrukRequest” name=”getWerkDrukRequest”/>
    <wsdl:output message=”tns:getWerkDrukResponse” name=”getWerkDrukResponse”/>
    <wsdl:fault message=”tns:WerkDrukException” name=”WerkDrukException”/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name=”WerkDrukServiceHttpBinding” type=”tns:WerkDrukServicePortType”>
    <wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/&gt;
    <wsdl:operation name=”getWerkDruk”>
    <wsdlsoap:operation soapAction=””/>
    <wsdl:input name=”getWerkDrukRequest”>
    <wsdlsoap:body use=”literal”/>
    </wsdl:input>
    <wsdl:output name=”getWerkDrukResponse”>
    <wsdlsoap:body use=”literal”/>
    </wsdl:output>
    <wsdl:fault name=”WerkDrukException”>
    <wsdlsoap:fault name=”WerkDrukException” use=”literal”/>
    </wsdl:fault>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name=”WerkDrukService”>
    <wsdl:port binding=”tns:WerkDrukServiceHttpBinding” name=”WerkDrukServiceHttpPort”>
    <wsdlsoap:address location=”http://localhost:8080/WerkDrukService/services/WerkDrukService”/&gt;
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

    The Client
    ————
    package com.brabo.tests;
    import java.net.MalformedURLException;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;

    import org.codehaus.xfire.XFireFactory;
    import org.codehaus.xfire.client.XFireProxyFactory;
    import org.codehaus.xfire.service.Service;
    import org.codehaus.xfire.service.binding.ObjectServiceFactory;

    //import brabo.util.StatistiekRecord;
    //import brabo.werkdruk.WerkDrukException;

    /**
    *
    */

    /**
    * @author JOHKENE
    *
    */
    public class TestClient {

    /**
    * @param args
    */
    public static void main(String[] args) {
    try {
    Service srvcModel = new
    ObjectServiceFactory().create(IWerkDruk.class);
    XFireProxyFactory factory =
    new XFireProxyFactory(XFireFactory.newInstance().getXFire());
    String WerkDrukServiceURL =
    http://localhost:8080/WerkDrukService/services/WerkDrukService&#8221;;
    IWerkDruk srvc = (IWerkDruk)factory.create(srvcModel, WerkDrukServiceURL);
    Date avan = (Date) new SimpleDateFormat(“dd-MM-yyyy HH:mm”).parse(“01-06-2006 00:00”);
    Date atot = (Date) new SimpleDateFormat(“dd-MM-yyyy HH:mm”).parse(“30-06-2006 23:59”);
    ArrayList<StatistiekRecord> results = null;
    results = srvc.getWerkDruk(avan, atot, new Float(8000));

    System.out.print(results);
    } catch (MalformedURLException e) {
    e.printStackTrace();
    } catch (ParseException e) {
    e.printStackTrace();
    } catch (WerkDrukException e) {
    e.printStackTrace();
    }
    }
    }

    #261421 Reply

    Riyad Kalla
    Member

    Johan,
    Is your:

    com.brabo.tests.StatistiekRecord

    class getting deployed with the webservice as part of the project or is this from another project or library that could possibly not be getting deployed correctly?

    #261455 Reply

    Johan Kenens
    Member

    You are right. That class was copied to the wrong package. The client is now OK.
    Although everything is working OK now the WSDL validation error is still bothering me.
    Any idea? In the web services explorer I also get an idication that there is something wrong with the WSDL
    Is this an XFire issue?

    You are great help!

    Johan

    Here is what I get after opening the WSDL:

    IWAB0380E Errors were encountered while validating XML schemas.
    XSD: Type reference ‘http://werkdruk.brabo#WerkDrukException&#8217; is unresolved
    IWAB0381I http://localhost:8080/WerkDrukService/services/WerkDrukService?WSDL was successfully opened.

    Here is the WSDL again with validation error in Bold

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <wsdl:definitions xmlns:ns1=”http://util.brabo&#8221; xmlns:ns2=”http://werkdruk.brabo&#8221; xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope&#8221; xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding&#8221; xmlns:tns=”http://loodsen.werkdruk.brabo&#8221; xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/&#8221; xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; targetNamespace=”http://loodsen.werkdruk.brabo”&gt;
    <wsdl:types>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://loodsen.werkdruk.brabo”&gt;
    <xsd:element name=”getWerkDruk”>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”avan” type=”xsd:dateTime”/>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”atot” type=”xsd:dateTime”/>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”awerkuren” nillable=”true” type=”xsd:float”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name=”getWerkDrukResponse”>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”out” nillable=”true” type=”ns1:ArrayOfStatistiekRecord”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name=”WerkDrukException” type=”ns2:WerkDrukException”/>
    </xsd:schema>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://util.brabo”&gt;
    <xsd:complexType name=”ArrayOfStatistiekRecord”>
    <xsd:sequence>
    <xsd:element maxOccurs=”unbounded” minOccurs=”0″ name=”StatistiekRecord” nillable=”true” type=”ns1:StatistiekRecord”/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name=”StatistiekRecord”>
    <xsd:sequence>
    <xsd:element minOccurs=”0″ name=”statistiek” nillable=”true” type=”xsd:string”/>
    <xsd:element minOccurs=”0″ name=”waarde” nillable=”true” type=”xsd:anyType”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://www.w3.org/2001/XMLSchema”/&gt;
    <xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://werkdruk.brabo”&gt;
    <xsd:complexType name=”WerkDrukException”>
    <xsd:sequence>
    <xsd:element minOccurs=”0″ name=”message” nillable=”true” type=”xsd:string”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    </wsdl:types>
    <wsdl:message name=”getWerkDrukRequest”>
    <wsdl:part element=”tns:getWerkDruk” name=”parameters”/>
    </wsdl:message>
    <wsdl:message name=”getWerkDrukResponse”>
    <wsdl:part element=”tns:getWerkDrukResponse” name=”parameters”/>
    </wsdl:message>
    <wsdl:message name=”WerkDrukException”>
    <wsdl:part element=”tns:WerkDrukException” name=”WerkDrukException”/>
    </wsdl:message>
    <wsdl:portType name=”WerkDrukServicePortType”>
    <wsdl:operation name=”getWerkDruk”>
    <wsdl:input message=”tns:getWerkDrukRequest” name=”getWerkDrukRequest”/>
    <wsdl:output message=”tns:getWerkDrukResponse” name=”getWerkDrukResponse”/>
    <wsdl:fault message=”tns:WerkDrukException” name=”WerkDrukException”/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name=”WerkDrukServiceHttpBinding” type=”tns:WerkDrukServicePortType”>
    <wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/&gt;
    <wsdl:operation name=”getWerkDruk”>
    <wsdlsoap:operation soapAction=””/>
    <wsdl:input name=”getWerkDrukRequest”>
    <wsdlsoap:body use=”literal”/>
    </wsdl:input>
    <wsdl:output name=”getWerkDrukResponse”>
    <wsdlsoap:body use=”literal”/>
    </wsdl:output>
    <wsdl:fault name=”WerkDrukException”>
    <wsdlsoap:fault name=”WerkDrukException” use=”literal”/>
    </wsdl:fault>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name=”WerkDrukService”>
    <wsdl:port binding=”tns:WerkDrukServiceHttpBinding” name=”WerkDrukServiceHttpPort”>
    <wsdlsoap:address location=”http://localhost:8080/WerkDrukService/services/WerkDrukService”/&gt;
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>[/b]

    #261465 Reply

    Johan Kenens
    Member

    Some additional info

    Validation error 1
    ——————–
    src-resolve.4.2: Error resolving component ‘ns1:ArrayOfStatistiekRecord’. It was detected that ‘ns1:ArrayOfStatistiekRecord’ is in namespace ‘http://util.brabo&#8217;, but components from this namespace are not referenceable from schema document ‘file:///C:/MyEclipseWorkspace/WerkDrukService/temp.wsdl’. If this is the incorrect namespace, perhaps the prefix of ‘ns1:ArrayOfStatistiekRecord’ needs to be changed. If this is the correct namespace, then an appropriate ‘import’ tag should be added to ‘file:///C:/MyEclipseWorkspace/WerkDrukService/temp.wsdl’.

    Validation error 2
    ——————–
    src-resolve.4.2: Error resolving component ‘ns2:WerkDrukException’. It was detected that ‘ns2:WerkDrukException’ is in namespace ‘http://werkdruk.brabo&#8217;, but components from this namespace are not referenceable from schema document ‘file:///C:/MyEclipseWorkspace/WerkDrukService/temp.wsdl’. If this is the incorrect namespace, perhaps the prefix of ‘ns2:WerkDrukException’ needs to be changed. If this is the correct namespace, then an appropriate ‘import’ tag should be added to ‘file:///C:/MyEclipseWorkspace/WerkDrukService/temp.wsdl’.

    Thanks
    Johan

    #261476 Reply

    Riyad Kalla
    Member

    Johan,
    I got the same two error markers when I used your WSDL file. I also pasted the example into a few other XML editors from other products and got errors as well, except different errors… I don’t think this file is valid for whatever quirky reason (XML baffles me sometimes).

    #261643 Reply

    Johan Kenens
    Member

    This is the WSDL generated by Xfire! Should I ask them for an explanation?

    Johan

    #261669 Reply

    Riyad Kalla
    Member

    Well that’s not good… have you checked the bug tracker for anyone else complaining about a similar issue?

    #262758 Reply

    qnob
    Member

    Hi! I got the same Fault with the message “Couldn’t instantiate class…” because of missing default constructor.

    #262768 Reply

    Riyad Kalla
    Member

    Ahh, good find gnob, thanks for posting.

    #262773 Reply

    qnob
    Member

    Never mind! I thank you for your support and for your nice plugin collection.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Questions on WSDl, complex datatypes and WS Client

You must be logged in to post in the forum log in