Java Mailing List Archive

http://www.java2.5341.com/

Home » axis-user.ws »

RE: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not
serialize

Attharkar, Asmita

2008-07-07

Replies: Find Java Web Hosting

Author LoginPost Reply

In this particular service, the client is sending a file as an attachment and the service saves the attachment into local drive.

I get this exception “Unknown type cannot serialize” when trying to send out the file as an attachment. It is a pdf file.


From: Attharkar, Asmita [mailto:aatthark@telcordia.com]
Sent: Monday, July 07, 2008 10:55 AM
To: axis-user@ws.apache.org
Subject: RE: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not serialize

 

Thilina,

Yes I have the wsdl for the service, The service is under my control and not external.

Here is the wsdl file

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://NPCWebService.mycompany.com" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ns="http://NPCWebService.mycompany.com/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://NPCWebService.mycompany.com">

    <wsdl:types>

        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://NPCWebService.mycompany.com/xsd">

            <xs:element name="processNPCMsg">

                <xs:complexType>

                    <xs:sequence>

                        <xs:element minOccurs="0" name="userId" nillable="true" type="xs:string"/>

                        <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>

                        <xs:element minOccurs="0" name="xmlMsg" nillable="true" type="xs:string"/>

                    </xs:sequence>

                </xs:complexType>

            </xs:element>

            <xs:element name="serviceMethodWithAttach">

                <xs:complexType>

                    <xs:sequence>

                        <xs:element minOccurs="0" name="userId" nillable="true" type="xs:string"/>

                        <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>

                        <xs:element minOccurs="0" name="XMLMsg" nillable="true" type="xs:string"/>

                        <xs:element minOccurs="0" name="element" nillable="true" type="xs:anyType"/>

                    </xs:sequence>

                </xs:complexType>

            </xs:element>

        </xs:schema>

    </wsdl:types>

    <wsdl:message name="serviceMethodWithAttachRequest">

        <wsdl:part name="parameters" element="ns:serviceMethodWithAttach"/>

    </wsdl:message>

    <wsdl:message name="processNPCMsgRequest">

        <wsdl:part name="parameters" element="ns:processNPCMsg"/>

    </wsdl:message>

    <wsdl:portType name="NPCWebServicePortType">

        <wsdl:operation name="serviceMethodWithAttach">

            <wsdl:input message="axis2:serviceMethodWithAttachRequest" wsaw:Action="urn:serviceMethodWithAttach"/>

        </wsdl:operation>

        <wsdl:operation name="processNPCMsg">

            <wsdl:input message="axis2:processNPCMsgRequest" wsaw:Action="urn:processNPCMsg"/>

        </wsdl:operation>

    </wsdl:portType>

    <wsdl:binding name="NPCWebServiceSoap11Binding" type="axis2:NPCWebServicePortType">

        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

        <wsdl:operation name="serviceMethodWithAttach">

            <soap:operation soapAction="urn:serviceMethodWithAttach" style="document"/>

            <wsdl:input>

                <soap:body use="literal"/>

            </wsdl:input>

        </wsdl:operation>

        <wsdl:operation name="processNPCMsg">

            <soap:operation soapAction="urn:processNPCMsg" style="document"/>

            <wsdl:input>

                <soap:body use="literal"/>

            </wsdl:input>

        </wsdl:operation>

    </wsdl:binding>

    <wsdl:binding name="NPCWebServiceSoap12Binding" type="axis2:NPCWebServicePortType">

        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

        <wsdl:operation name="serviceMethodWithAttach">

            <soap12:operation soapAction="urn:serviceMethodWithAttach" style="document"/>

            <wsdl:input>

                <soap12:body use="literal"/>

            </wsdl:input>

        </wsdl:operation>

        <wsdl:operation name="processNPCMsg">

            <soap12:operation soapAction="urn:processNPCMsg" style="document"/>

            <wsdl:input>

                <soap12:body use="literal"/>

            </wsdl:input>

        </wsdl:operation>

    </wsdl:binding>

    <wsdl:binding name="NPCWebServiceHttpBinding" type="axis2:NPCWebServicePortType">

        <http:binding verb="POST"/>

        <wsdl:operation name="serviceMethodWithAttach">

            <http:operation location="NPCWebService/serviceMethodWithAttach"/>

            <wsdl:input>

                <mime:content type="text/xml" part="serviceMethodWithAttach"/>

            </wsdl:input>

        </wsdl:operation>

        <wsdl:operation name="processNPCMsg">

            <http:operation location="NPCWebService/processNPCMsg"/>

            <wsdl:input>

                <mime:content type="text/xml" part="processNPCMsg"/>

            </wsdl:input>

        </wsdl:operation>

    </wsdl:binding>

    <wsdl:service name="NPCWebService">

        <wsdl:port name="NPCWebServiceHttpSoap11Endpoint" binding="axis2:NPCWebServiceSoap11Binding">

            <soap:address location="http://localhost:8080/axis2/services/NPCWebService"/>

        </wsdl:port>

        <wsdl:port name="NPCWebServiceHttpSoap12Endpoint" binding="axis2:NPCWebServiceSoap12Binding">

            <soap12:address location="http://localhost:8080/axis2/services/NPCWebService"/>

        </wsdl:port>

        <wsdl:port name="NPCWebServiceHttpEndpoint" binding="axis2:NPCWebServiceHttpBinding">

            <http:address location="http://localhost:8080/axis2/services/NPCWebService"/>

        </wsdl:port>

    </wsdl:service>

</wsdl:definitions>

 


From: Thilina Gunarathne [mailto:csethil@gmail.com]
Sent: Thursday, July 03, 2008 8:40 PM
To: axis-user@ws.apache.org
Subject: Re: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not serialize

 

 

 Will this method.addChild will not create the proper XML format when I send in the message?

What I mean by proper XML format is the XMLSchema which your service mandates your request should adhere to..

Do you have a proper WSDL for the service.. Is the service under ur control or something external..

~Thilina

     

           

            msgAttach.setUserId("Test");

            msgAttach.setPassword("test");

            msgAttach.setXMLMsg("<test></test>");

            msgAttach.setElement(method);

           

            myStub.processWithAttach(msgAttach);

 

Thanks,
Asmita

 


From: Thilina Gunarathne [mailto:csethil@gmail.com]
Sent: Thursday, July 03, 2008 2:48 PM

Subject: Re: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not serialize

 

Hi,
I'm a bit confused... Why are you creating the XML using Axiom while you have stubs generated... It would have been better if you fixed your wsdl to reflect the correct XML elements and code generated..

Looks like you are getting the fault from the serverside.  A message trace of the request and the WSDL of the service would help to figure out the problem clearly..

            myStub._getServiceClient().getOptions()

                        .setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

            myStub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);

            File file = new File(INPUT_FILE);

            FileInputStream fis = new FileInputStream(file);

            String base64String = Base64.encode(readFully(fis)); //reads the file bitwise before encode is called on it.

You can just create a DataHandler and create the OMText out of it... Trying to do the above will put in you in trouble if you are trying to send a larger attachment.

 

            OMText binaryNode =fac.createOMText(base64String,"application/pdf",true);

You can use the createOMText() with DataHandler..

 

 

Why do I get unknown type cannot serialize?

Chances are that you are not sending the message in the correct (XML hierachy) format..

thanks,
Thilina

 

Thanks,

Asmita


From: Tony Dean [mailto:Tony.Dean@sas.com]
Sent: Thursday, July 03, 2008 11:46 AM
To: axis-user@ws.apache.org
Subject: RE: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not serialize

 

don't know about your issue, but there are other issues fixed in 1.4 that were broke in 1.3 so I wouldn't go back there.

 

From: Attharkar, Asmita [mailto:aatthark@telcordia.com]
Sent: Thursday, July 03, 2008 9:40 AM
To: axis-user@ws.apache.org
Subject: MTOM: Axis2-1.4 issue?? XMLStreamException: Unknow type can not serialize

 

All,

 

I am trying to send a pdf attachment in the soap message but I get this:

 

org.apache.axis2.databinding.utils.ConverterUtil.serializeAnyType(ConverterUtil.java:1449)

 

And the message doesn't come to web services server, it is failing in OperationClient.execute() method itself.

The AxisFault message shows "Unknow type can not serialize". What could be the possible reasons for this or is this a known issue with axis2 1.4 release? Should I use axis2 1.3 release if I need to send an attachment using MTOM?

 

Thanks so much for you help!

 

I am using JRE and JDK 1.5_15, Ant 1.6, apache tomcat server 1.6 and Axis2 1.4

 

Thanks,

Asmita

 




--
Thilina Gunarathne - http://thilinag.blogspot.com




--
Thilina Gunarathne - http://thilinag.blogspot.com

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.