- This topic has 9 replies, 3 voices, and was last updated 18 years, 1 month ago by qnob.
-
AuthorPosts
-
Johan KenensMemberHi,
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” xmlns:ns2=”http://werkdruk.brabo” xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope” xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding” xmlns:tns=”http://loodsen.werkdruk.brabo” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” targetNamespace=”http://loodsen.werkdruk.brabo”>
<wsdl:types>
<xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://loodsen.werkdruk.brabo”>
<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”>
<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”/>
<xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://werkdruk.brabo”>
<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”/>
<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”/>
</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”;
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();
}
}
}
Riyad KallaMemberJohan,
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?
Johan KenensMemberYou 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’ 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” xmlns:ns2=”http://werkdruk.brabo” xmlns:soap11=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:soap12=”http://www.w3.org/2003/05/soap-envelope” xmlns:soapenc11=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:soapenc12=”http://www.w3.org/2003/05/soap-encoding” xmlns:tns=”http://loodsen.werkdruk.brabo” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” targetNamespace=”http://loodsen.werkdruk.brabo”>
<wsdl:types>
<xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://loodsen.werkdruk.brabo”>
<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”>
<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”/>
<xsd:schema attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://werkdruk.brabo”>
<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”/>
<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”/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>[/b]
Johan KenensMemberSome 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’, 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’, 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
Riyad KallaMemberJohan,
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).
Johan KenensMemberThis is the WSDL generated by Xfire! Should I ask them for an explanation?
Johan
Riyad KallaMemberWell that’s not good… have you checked the bug tracker for anyone else complaining about a similar issue?
qnobMemberHi! I got the same Fault with the message “Couldn’t instantiate class…” because of missing default constructor.
Riyad KallaMemberAhh, good find gnob, thanks for posting.
qnobMemberNever mind! I thank you for your support and for your nice plugin collection.
-
AuthorPosts