Serialization problem, VB.Net Client consuming Java Axis Web Service

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Serialization problem, VB.Net Client consuming Java Axis Web Service

    I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem serializing the object but there seems to be a problem serializing an array of objects. Any help will be appreciated

    "Cannot assign object of type System.Object[] to an object of type ElectronicWallet.C2PTest.PaymentItem."

    [System.InvalidOperationException]: {System.InvalidOperationException
    HelpLink: Nothin
    InnerException: {System.InvalidCastException
    Message: "There is an error in XML document (12, 19).
    Source: "System.Xml

    StackTrace: " at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, String encodingStyle
    at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader
    at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall
    at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters
    at ElectronicWallet.C2PTest.SOAPPaymentServiceService .method1(String par1, String par2, String par3, Int64 par4, String par5, String par6, Boolean par7, String par8, String par9, String par10, String par11) in C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\Web References\C2PTest\Reference.vb:line 4
    at ElectronicWallet.PayoutCommon.DoPayout(Int64 lngTransID, XmlDocument& oWSReq, XmlDocument& oWSResp) in C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\PayoutCommon.vb:line 22
    at ElectronicWallet.Process.EWPayout(String s_Payout) in C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\Process.asmx.vb:line 153
    TargetSite: {System.Reflection.RuntimeMethodInfo
    ?ex.InnerException
    {System.InvalidCastException
    [System.InvalidCastException]: {System.InvalidCastException
    HelpLink: Nothin
    InnerException: Nothin
    Message: "Cannot assign object of type System.Object[] to an object of type ElectronicWallet.C2PTest.PaymentItem[].
    Source: "fqsomxwu
    StackTrace: " at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read3_ResponsePar6l(
    at System.Xml.Serialization.XmlSerializationReader.Re adReferencingElement(String name, String ns, Boolean elementCanBeType, String& fixupReference
    at System.Xml.Serialization.XmlSerializationReader.Re adReferencedElements(
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read6_method1Response()
    TargetSite: {System.Reflection.RuntimeMethodInfo

    Related code from .NET proxy class............................

    '<remarks/
    <System.Web.Services.Protocols.SoapRpcMethodAttrib ute("", RequestNamespace:="http://somewebsite", ResponseNamespace:="https://somewebsite/method1")>
    Public Function method1(ByVal par1 As String, ByVal par2 As String, ByVal par3 As String, ByVal par4 As Long, ByVal par5 As String, ByVal par6 As String, ByVal par7 As Boolean, ByVal par8 As String, ByVal par9 As String, ByVal par10 As String, ByVal par11 As String) As <System.Xml.Serialization.SoapElementAttribute("me thod1Return")> ResponseMode
    Dim results() As Object = Me.Invoke("method1", New Object() {par1, par2, par3,_u97 ?mount, par5, par6, par7, par8, par9, par10, par11}

    Return CType(results(0),ResponseModel
    End Functio

    '<remarks/
    <System.Xml.Serialization.SoapTypeAttribute("Respo nseModel", "http://somewebsite")>
    Public Class ResponseMode

    '<remarks/
    Public ret1 As Strin

    '<remarks/
    Public ret2 As Strin

    '<remarks/
    Public ret 3 As Strin

    '<remarks/
    Public paymentItems() As PaymentIte
    End Clas

    '<remarks/
    <System.Xml.Serialization.SoapTypeAttribute("Payme ntItem", "http://somewebsite")>
    Public Class PaymentIte

    '<remarks/
    Public ret4 As Strin

    '<remarks/
    Public ret5 As Strin

    '<remarks/>
    Public ret6 As String
    End Class


    Here is the VB.NET code.............................

    Dim SoapRequest As New C2PTest.SOAPPaymentServiceService
    Dim C2PResult As New C2PTest.ResponseModel
    Dim Dict As New Collections.Specialized.StringDictionary
    C2PResult = SoapRequest.method1(Dict("par1"), Dict("par2"), Dict("par3"), Dict("par4"), _
    Dict("par5"), Dict("Par6"), Dict("par7"), Dict("par8"), Dict("par9"), _
    Dict("par10"), Dict("par11"))


    Here is the WSDL file.............................

    <wsdl:definitions targetNamespace="https://somewebsite/method1" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="https://somewebsite/method1" xmlns:intf="https://somewebsite/method1" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://somewebsite" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
    <schema targetNamespace="http://somewebsite" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    <complexType name="PaymentItem">
    <sequence>
    <element name="ret4" nillable="true" type="xsd:string"/>
    <element name="ret5" nillable="true" type="xsd:string"/>
    <element name="ret6" nillable="true" type="xsd:string"/>
    </sequence>
    </complexType>
    <complexType name="ResponseModel">
    <sequence>
    <element name="ret1" nillable="true" type="xsd:string"/>
    <element name="ret2" nillable="true" type="xsd:string"/>
    <element name="ret3" nillable="true" type="xsd:string"/>
    <element name="paymentItems" nillable="true" type="impl:ArrayOf_tns1_PaymentItem"/>
    </sequence>
    </complexType>
    </schema>
    <schema targetNamespace="https://somewebsite/method1" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    <complexType name="ArrayOf_tns1_PaymentItem">
    <complexContent>
    <restriction base="soapenc:Array">
    <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:PaymentItem[]"/>
    </restriction>
    </complexContent>
    </complexType>
    </schema>
    </wsdl:types>
    <wsdl:message name="method1Request">
    <wsdl:part name="par1" type="xsd:string"/>
    <wsdl:part name="par2" type="xsd:string"/>
    <wsdl:part name="par3" type="xsd:string"/>
    <wsdl:part name="par4" type="xsd:long"/>
    <wsdl:part name="par5" type="xsd:string"/>
    <wsdl:part name="par6" type="xsd:string"/>
    <wsdl:part name="par7" type="xsd:boolean"/>
    <wsdl:part name="par8" type="xsd:string"/>
    <wsdl:part name="par9" type="xsd:string"/>
    <wsdl:part name="par10" type="xsd:string"/>
    <wsdl:part name="par11" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="method1Response">
    <wsdl:part name="method1Return" type="tns1:ResponseModel"/>
    </wsdl:message>
    <wsdl:portType name="SOAPPaymentService">
    <wsdl:operation name="method1" parameterOrder="par1 par2 par3 par4 par5 par6 par7 par8 par9 par10 par11">
    <wsdl:input message="impl:method1Request" name="method1Request"/>
    <wsdl:output message="impl:method1Response" name="method1Response"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="method1SoapBinding" type="impl:SOAPPaymentService">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="method1">
    <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="method1Request">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://somewebsite" use="encoded"/>
    </wsdl:input>
    <wsdl:output name="method1Response">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="https://somewebsite/method1" use="encoded"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SOAPPaymentServiceService">
    <wsdl:port binding="impl:method1SoapBinding" name="method1">
    <wsdlsoap:address location="https://somewebsite/method1"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>




    ---
    Posted using Wimdows.net Newsgroups - [url]http://www.wimdows.net/newsgroups/[/url]
    umhlali Guest

  2. Similar Questions and Discussions

    1. Consuming Java web service from .Net
      sush M via .NET 247 <anonymous@dotnet247.com> wrote in news:eEQOYiUWFHA.3076@TK2MSFTNGP12.phx.gbl: Generate the proxy, then you can change the...
    2. consuming java web service
      Hi, I'm writting a code in C# which needs to consume a Java-written web service. This service was written in a RPC/Literal way, so I've used a...
    3. .NET Client / Java Web Service Problem
      Hi, I am writting a .NET Client for a Java Web Service.I have createda .cs file from the WSDL and the XSD's Given. I am trying to query a Web...
    4. System.InvalidCastException in .Net client consuming Axis 1.1 java web service
      Hi, I am developing a .Net client for Axis 1.1 web service written in java. The wsdl is generated using, java2WSDL with these switches:: -y WRAPPED...
    5. Interop issue with Java/Axis web service - Authentication problem
      Hi John, Thank you for using the community. As I understand, you have set Credentials property for a web service client and found it will post...
  3. #2

    Default Re: Serialization problem, VB.Net Client consuming Java Axis Web Service

    the WSDL file - how did you generate this? Is it auto-generated by AXIS?

    Can you try this: Wrap the array of objects in an object.
    Eg, rather than a method signature like this:

    MyObject[] WebServiceMethod(RequestMessage req)

    Do this:

    ResponseMessage WebServiceMethod(RequestMessage req)

    where
    public ResponseMessage {
    MyObject[] ary;
    }

    -Dino

    "umhlali" <andilem@-NOSPAM-mercantrade.com> wrote in message
    news:ewvuFB9QEHA.3452@TK2MSFTNGP10.phx.gbl...
    > I get the following exception when my VB.NET app calls a Java web service
    that returns an array of objects. The same call works for a single object
    though. So looks like there is no problem serializing the object but there
    seems to be a problem serializing an array of objects. Any help will be
    appreciated.
    >
    > "Cannot assign object of type System.Object[] to an object of type
    ElectronicWallet.C2PTest.PaymentItem."
    >
    > [System.InvalidOperationException]: {System.InvalidOperationException}
    > HelpLink: Nothing
    > InnerException: {System.InvalidCastException}
    > Message: "There is an error in XML document (12, 19)."
    > Source: "System.Xml"
    >
    > StackTrace: " at
    System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
    String encodingStyle)
    > at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
    xmlReader)
    > at
    System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClient
    Message message, WebResponse response, Stream responseStream, Boolean
    asyncCall)
    > at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
    methodName, Object[] parameters)
    > at ElectronicWallet.C2PTest.SOAPPaymentServiceService .method1(String
    par1, String par2, String par3, Int64 par4, String par5, String par6,
    Boolean par7, String par8, String par9, String par10, String par11) in
    C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\Web
    References\C2PTest\Reference.vb:line 43
    > at ElectronicWallet.PayoutCommon.DoPayout(Int64 lngTransID,
    XmlDocument& oWSReq, XmlDocument& oWSResp) in
    C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\PayoutCommon
    ..vb:line 225
    > at ElectronicWallet.Process.EWPayout(String s_Payout) in
    C:\Projects\Gateway\ElectronicWallet\ElectronicWal letWebService\Process.asmx
    ..vb:line 153"
    > TargetSite: {System.Reflection.RuntimeMethodInfo}
    > ?ex.InnerException
    > {System.InvalidCastException}
    > [System.InvalidCastException]: {System.InvalidCastException}
    > HelpLink: Nothing
    > InnerException: Nothing
    > Message: "Cannot assign object of type System.Object[] to an object of
    type ElectronicWallet.C2PTest.PaymentItem[]."
    > Source: "fqsomxwu"
    > StackTrace: " at
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read3_
    ResponsePar6l()
    > at
    System.Xml.Serialization.XmlSerializationReader.Re adReferencingElement(Strin
    g name, String ns, Boolean elementCanBeType, String& fixupReference)
    > at
    System.Xml.Serialization.XmlSerializationReader.Re adReferencedElements()
    > at
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read6_
    method1Response()"
    > TargetSite: {System.Reflection.RuntimeMethodInfo}
    >
    > Related code from .NET proxy class.............................
    >
    > '<remarks/>
    > <System.Web.Services.Protocols.SoapRpcMethodAttrib ute("",
    RequestNamespace:="http://somewebsite",
    ResponseNamespace:="https://somewebsite/method1")> _
    > Public Function method1(ByVal par1 As String, ByVal par2 As String, ByVal
    par3 As String, ByVal par4 As Long, ByVal par5 As String, ByVal par6 As
    String, ByVal par7 As Boolean, ByVal par8 As String, ByVal par9 As String,
    ByVal par10 As String, ByVal par11 As String) As
    <System.Xml.Serialization.SoapElementAttribute("me thod1Return")>
    ResponseModel
    > Dim results() As Object = Me.Invoke("method1", New Object() {par1,
    par2, par3,_u97 ?mount, par5, par6, par7, par8, par9, par10, par11})
    >
    > Return CType(results(0),ResponseModel)
    > End Function
    >
    > '<remarks/>
    > <System.Xml.Serialization.SoapTypeAttribute("Respo nseModel",
    "http://somewebsite")> _
    > Public Class ResponseModel
    >
    > '<remarks/>
    > Public ret1 As String
    >
    > '<remarks/>
    > Public ret2 As String
    >
    > '<remarks/>
    > Public ret 3 As String
    >
    > '<remarks/>
    > Public paymentItems() As PaymentItem
    > End Class
    >
    > '<remarks/>
    > <System.Xml.Serialization.SoapTypeAttribute("Payme ntItem",
    "http://somewebsite")> _
    > Public Class PaymentItem
    >
    > '<remarks/>
    > Public ret4 As String
    >
    > '<remarks/>
    > Public ret5 As String
    >
    > '<remarks/>
    > Public ret6 As String
    > End Class
    >
    >
    > Here is the VB.NET code.............................
    >
    > Dim SoapRequest As New C2PTest.SOAPPaymentServiceService
    > Dim C2PResult As New C2PTest.ResponseModel
    > Dim Dict As New Collections.Specialized.StringDictionary
    > C2PResult = SoapRequest.method1(Dict("par1"), Dict("par2"), Dict("par3"),
    Dict("par4"), _
    > Dict("par5"), Dict("Par6"), Dict("par7"), Dict("par8"), Dict("par9"), _
    > Dict("par10"), Dict("par11"))
    >
    >
    > Here is the WSDL file.............................
    >
    > <wsdl:definitions targetNamespace="https://somewebsite/method1"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:apachesoap="http://xml.apache.org/xml-soap"
    xmlns:impl="https://somewebsite/method1"
    xmlns:intf="https://somewebsite/method1"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tns1="http://somewebsite"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    > <wsdl:types>
    > <schema targetNamespace="http://somewebsite"
    xmlns="http://www.w3.org/2001/XMLSchema">
    > <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    > <complexType name="PaymentItem">
    > <sequence>
    > <element name="ret4" nillable="true" type="xsd:string"/>
    > <element name="ret5" nillable="true" type="xsd:string"/>
    > <element name="ret6" nillable="true" type="xsd:string"/>
    > </sequence>
    > </complexType>
    > <complexType name="ResponseModel">
    > <sequence>
    > <element name="ret1" nillable="true" type="xsd:string"/>
    > <element name="ret2" nillable="true" type="xsd:string"/>
    > <element name="ret3" nillable="true" type="xsd:string"/>
    > <element name="paymentItems" nillable="true"
    type="impl:ArrayOf_tns1_PaymentItem"/>
    > </sequence>
    > </complexType>
    > </schema>
    > <schema targetNamespace="https://somewebsite/method1"
    xmlns="http://www.w3.org/2001/XMLSchema">
    > <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    > <complexType name="ArrayOf_tns1_PaymentItem">
    > <complexContent>
    > <restriction base="soapenc:Array">
    > <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:PaymentItem[]"/>
    > </restriction>
    > </complexContent>
    > </complexType>
    > </schema>
    > </wsdl:types>
    > <wsdl:message name="method1Request">
    > <wsdl:part name="par1" type="xsd:string"/>
    > <wsdl:part name="par2" type="xsd:string"/>
    > <wsdl:part name="par3" type="xsd:string"/>
    > <wsdl:part name="par4" type="xsd:long"/>
    > <wsdl:part name="par5" type="xsd:string"/>
    > <wsdl:part name="par6" type="xsd:string"/>
    > <wsdl:part name="par7" type="xsd:boolean"/>
    > <wsdl:part name="par8" type="xsd:string"/>
    > <wsdl:part name="par9" type="xsd:string"/>
    > <wsdl:part name="par10" type="xsd:string"/>
    > <wsdl:part name="par11" type="xsd:string"/>
    > </wsdl:message>
    > <wsdl:message name="method1Response">
    > <wsdl:part name="method1Return" type="tns1:ResponseModel"/>
    > </wsdl:message>
    > <wsdl:portType name="SOAPPaymentService">
    > <wsdl:operation name="method1" parameterOrder="par1 par2 par3 par4 par5
    par6 par7 par8 par9 par10 par11">
    > <wsdl:input message="impl:method1Request" name="method1Request"/>
    > <wsdl:output message="impl:method1Response" name="method1Response"/>
    > </wsdl:operation>
    > </wsdl:portType>
    > <wsdl:binding name="method1SoapBinding" type="impl:SOAPPaymentService">
    > <wsdlsoap:binding style="rpc"
    transport="http://schemas.xmlsoap.org/soap/http"/>
    > <wsdl:operation name="method1">
    > <wsdlsoap:operation soapAction=""/>
    > <wsdl:input name="method1Request">
    > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="http://somewebsite" use="encoded"/>
    > </wsdl:input>
    > <wsdl:output name="method1Response">
    > <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="https://somewebsite/method1" use="encoded"/>
    > </wsdl:output>
    > </wsdl:operation>
    > </wsdl:binding>
    > <wsdl:service name="SOAPPaymentServiceService">
    > <wsdl:port binding="impl:method1SoapBinding" name="method1">
    > <wsdlsoap:address location="https://somewebsite/method1"/>
    > </wsdl:port>
    > </wsdl:service>
    > </wsdl:definitions>
    >
    >
    >
    >
    > ---
    > Posted using Wimdows.net Newsgroups - [url]http://www.wimdows.net/newsgroups/[/url]

    Dino Chiesa [Microsoft] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139