my dog learned polymorphism*
The moose likes Web Services and the fly likes Axis org.xml.sax.SAXException: Bad types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis org.xml.sax.SAXException: Bad types" Watch "Axis org.xml.sax.SAXException: Bad types" New topic
Author

Axis org.xml.sax.SAXException: Bad types

W Steyn
Greenhorn

Joined: Apr 03, 2004
Posts: 3
I will appreciate it if someone could please help me out with this error. Somehow the XML and JavaBeans appear to be out of sync. We created the client classes with WSDL2Java and I think there might be some errors in the classes even though they compile. There has been some discussions surrounding these types of errors but no real answer and to the cause.
The call to the invoke method produces the error below
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {merchant, documentIdentifier.value});
Error:
org.xml.sax.SAXException: Bad types (class nsMerchantDataExchange.DocumentID -> class javax.activation.DataHandler)
Small sample of WSDL file:
<wsdl peration name="getDocument" parameterOrder="merchant documentIdentifier">
<wsdl:input message="tns:MerchantDataExchange_getDocument_Request" name="getDocument"/>
<wsdl utput message="tns:MerchantDataExchange_getDocument_Response" name="getDocument"/>
<wsdl:fault message="tns:MerchantDataExchange_Fault" name="getDocument"/>
</wsdl peration>

<wsdl peration name="getDocument">
<soap peration soapAction="" style="rpc"/>
<wsdl:input name="getDocument">
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="nsMerchantDataExchange"
use="encoded"/>
</wsdl:input>
<wsdl utput name="getDocument">
<mime:multipartRelated>
<mime art>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="nsMerchantDataExchange"
use="encoded"/>
</mime art>
<mime art>
<mime:content part="document" type="application/binary"/>
</mime art>
</mime:multipartRelated>
</wsdl utput>

<wsdl:fault name="getDocument">
<soap:fault
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="nsMerchantDataExchange"
use="encoded"/>
</wsdl:fault>
</wsdl peration>
Document Class that appears to be the bad type.
public class DocumentID implements java.io.Serializable, org.apache.axis.encoding.SimpleType {
private java.lang.String value;
public DocumentID() {
}
// Simple Types must have a String constructor
public DocumentID(java.lang.String value) {
this.value = value;
}
// Simple Types must have a toString for serializing the value
public java.lang.String toString() {
return value;
}

/**
* Gets the value value for this DocumentID.
*
* @return value
*/
public java.lang.String getValue() {
return value;
}

/**
* Sets the value value for this DocumentID.
*
* @param value
*/
public void setValue(java.lang.String value) {
this.value = value;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof DocumentID)) return false;
DocumentID other = (DocumentID) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.value==null && other.getValue()==null) ||
(this.value!=null &&
this.value.equals(other.getValue())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getValue() != null) {
_hashCode += getValue().hashCode();
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(DocumentID.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("nsMerchantDataExchange", "DocumentID"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("value");
elemField.setXmlName(new javax.xml.namespace.QName("", "value"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.SimpleSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.SimpleDeserializer(
_javaType, _xmlType, typeDesc);
}
}
W Steyn
Greenhorn

Joined: Apr 03, 2004
Posts: 3
Here is some more code that might help. Thanks.
oper = new org.apache.axis.description.OperationDesc();
oper.setName("getDocument");
oper.addParameter(new javax.xml.namespace.QName("", "merchant"), new javax.xml.namespace.QName("nsMerchantDataExchange", "Merchant"), nsMerchantDataExchange.Merchant.class, org.apache.axis.description.ParameterDesc.IN, false, false);
oper.addParameter(new javax.xml.namespace.QName("", "documentIdentifier"), new javax.xml.namespace.QName("nsMerchantDataExchange", "DocumentID"), nsMerchantDataExchange.DocumentID.class, org.apache.axis.description.ParameterDesc.INOUT, false, false);
oper.setReturnType(new javax.xml.namespace.QName("http://xml.apache.org/xml-soap", "DataHandler"));
oper.setReturnClass(javax.activation.DataHandler.class);
oper.setReturnQName(new javax.xml.namespace.QName("", "document"));
oper.setStyle(org.apache.axis.enum.Style.RPC);
oper.setUse(org.apache.axis.enum.Use.ENCODED);
oper.addFault(new org.apache.axis.description.FaultDesc(
new javax.xml.namespace.QName("nsMerchantDataExchange", "response"),
"nsMerchantDataExchange.Fault",
new javax.xml.namespace.QName("nsMerchantDataExchange", "Fault"),
true
));
_operations[8] = oper;
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[8]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("");
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("nsMerchantDataExchange", "getDocument"));
_call.setUsername("steynwe@wwwinc.com");
_call.setPassword("amazon");
setRequestHeaders(_call);
setAttachments(_call);
System.out.println("1111");
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {merchant, documentIdentifier.value});
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Just a tip: Use UBB codes for formatting your post (specifically, encapsulate code blocks with [CODE]...[/CODE] to preserve indentation).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis org.xml.sax.SAXException: Bad types
 
Similar Threads
Apache axis
CONSUMING .NET DATASET IN JAVA CLIENT
Need Help regarding -- org.xml.sax.SAXException: Invalid element
How to pass an object as a parameter in web services?
Compare these classes!