Question

Created a new web service client for axis2 webservice on my .net application. Calling some methods of webservice. .Net is calling webservice and read xml response but can not deserialize it. Generated proxy code is normally for .net, its ok. wsdl is passed wsi compliance.

With wireshark i saw xml response is very normal. web service is responses the request normally but xml data is seem wrongly. let me show same data and contracts.

xml response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:blablaResponse xmlns:ns="http://blabla">
      <ns:return type="blablaMessage" xmlns:ax274="http://blabla/xsd" xmlns:ax272="http://blabla/xsd" xmlns:ax271="http://blabla/xsd">
        <ax274:blablaNo>1</ax274:blablaNo>
        <ax274:blablaNo>2</ax274:blablaNo>
        <ax274:blablaNo>3</ax274:blablaNo>
        <ax274:blablaDescription>TEXT 1</ax274:blablaDescription>
        <ax274:blablaDescription>TEXT 2</ax274:blablaDescription>
        <ax274:blablaDescription>TEXT 3</ax274:blablaDescription>
        <ax274:statustype="blblaState">
          <ax272:textMessage/>
          <ax272:code>OK</ax272:code>
        </ax274:status>
      </ns:return>
    </ns:blablaResponse>
  </soapenv:Body>
</soapenv:Envelope>

auto generated data contract:

<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="blablaResponse", [Namespace]:="http://blabla"), _
System.SerializableAttribute()> _
Partial Public Class blablaMessage
    Inherits Object
    Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged

    <System.NonSerializedAttribute()> _
    Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject

    Private blablaNoField As ServiceReference1.ArrayOf_xsd_int

    Private blablaDesriptionField As ServiceReference1.ArrayOf_xsd_string

    Private statusField As ServiceReference1.status

    <Global.System.ComponentModel.BrowsableAttribute(False)> _
    Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
        Get
            Return Me.extensionDataField
        End Get
        Set(value As System.Runtime.Serialization.ExtensionDataObject)
            Me.extensionDataField = value
        End Set
    End Property

    <System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True)> _
    Public Property blablaNo() As ServiceReference1.ArrayOf_xsd_int
        Get
            Return Me.blablaNoField
        End Get
        Set(value As ServiceReference1.ArrayOf_xsd_int)
            If (Object.ReferenceEquals(Me.blablaNoField, value) <> True) Then
                Me.blablaNoField = value
                Me.RaisePropertyChanged("blablaNo")
            End If
        End Set
    End Property

    <System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True)> _
    Public Property blablaDescription() As ServiceReference1.ArrayOf_xsd_string
        Get
            Return Me.blablaDesriptionField
        End Get
        Set(value As ServiceReference1.ArrayOf_xsd_string)
            If (Object.ReferenceEquals(Me.blablaDesriptionField, value) <> True) Then
                Me.blablaDesriptionField = value
                Me.RaisePropertyChanged("blablaDescription")
            End If
        End Set
    End Property

    <System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True)> _
    Public Property status() As ServiceReference1.IslemSonucu
        Get
            Return Me.statusField
        End Get
        Set(value As ServiceReference1.IslemSonucu)
            If (Object.ReferenceEquals(Me.statusField, value) <> True) Then
                Me.statusField = value
                Me.RaisePropertyChanged("status")
            End If
        End Set
    End Property

    Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Protected Sub RaisePropertyChanged(ByVal propertyName As String)
        Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
        If (Not (propertyChanged) Is Nothing) Then
            propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
        End If
    End Sub
End Class

Tried wsdl.exe svcutil.exe with some various parameters thats all failed. It's seem a serialization problem with axis2 because different kind of elements in same xml parent. For example blablaNo and blablaDescription.

How can i solve this problem. Thanks.

Was it helpful?

Solution 2

publisher sent is to new wsdl file and problem is solved.

OTHER TIPS

As per the XML response your showing it is strange, blablaNo for me isn't a array of int but i read it as 3 int variables and they don't seems to have distinguishable names. Never seen XML formated like that but i never worked with Java service output before either.

You know, if i were you i would try to change the output of the Axis service to JSON. First it would be smaller and secondly it would completely remove confusion over output formatting. to De-serialize JSON in .net is really easy.

Here's a very simple example i am currently working on (3 differents service communication with each other and PHP page and .Net desktop app)

internal class CFingerPrint
{
    public string WanIP;
    public string MacAddress;      

    public string getClassEncrypted()
    {
        return new JavaScriptSerializer().Serialize(this);
    }

    public CFingerPrint getClassDecrypted(string sSerializedClass)
    {
        return new JavaScriptSerializer().Deserialize<CFingerPrint>(sSerializedClass);
    }
}

In JSON you don't need the fancy attributes everywhere for basic properties. Unless you return custom object you should be fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top