Subject: XML tags getting converted during exchange
Posted By: Koushik Post Date: 10/19/2006 5:28:09 AM
I have an Axis Web service developed on Java, which is accepting XML as input and returns XML as output. While I am invoking the webservice from Java client, the input is in form of a proper XML, while when I am invoking the web service from MS .NET client, the XML tags are getting distorted. i.e < is getting converted to &lt; and > is getting converted to &gt;. Can anyone help to locate and rectify the problem?

Reply By: mhkay Reply Date: 10/19/2006 5:41:29 AM
>Can anyone help to locate and rectify the problem?

Not without a lot more information, sorry.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: Koushik Reply Date: 10/23/2006 11:26:05 AM
My Web Service is written in Java, hoisted on Axis 1.1 platform. The Web service takes Element(of org.apache.w3c.Element) as input arguments and returns Element as output. It takes XML as input and returns XML as output. The XML exchange is supported on SOAP protocol. I am trying to access my webservice from .NET client. I have converted the WSDL file to generate the client stub. In the client code, I have defined an object of XmlDocument type and loaded an XML from XmlDocument.Load method and passed the XmlDocument.OuterXml as input. However, when I am monitoring the input on my webservice, I am receiving the SOAP envelop in XML(i.e with opening and closing angular bracket <>), but the XML content, read from the file is getting distorted. The < is getting converted to &lt; and > converted to &gt;. Please help.

Reply By: joefawcett Reply Date: 10/23/2006 11:55:23 AM
OuterXml is a string representation of the XML so that's what gets passed to the service. If the service expects an element then try passing XmlDocument.DocumentElement instead.

If the problem is strictly on the receiving side do you have a link to the WSDL?

--

Joe (Microsoft MVP - XML)
Reply By: Koushik Reply Date: 10/25/2006 11:37:50 PM
Tried the solution. But .NET is giving an error:System.InvaliOperationException: There was an error generating  the XML Document. -->The type System.Xml.XmlElement may not be used in this context.

Reply By: joefawcett Reply Date: 10/26/2006 2:19:21 AM
Okay, without the WSDL it's hard to help though.

--

Joe (Microsoft MVP - XML)
Reply By: Koushik Reply Date: 10/28/2006 7:30:44 AM
Hi
I have a web service hosted in WSAD developed in JAVA working on Axis 1.x platform. This web service receives an XML input and returns an XML output. I am trying to consume the web service from a .NET client.
I tried to create the proxy class to invoke the web service referred to by above WSDL by using the wsdl.exe utility of .NET.

I have written a seperate piece of code to invoke this proxy class and to invoke the web service in turn.
 Now, when I am invoking the web service from the caller class, I am passing the XML, but the return object is NULL. On inspection of the actual input to the web service, I found that the XML being passed to web service as SOAP body is getting distorted. The < of XML is getting converted to "&lt;" and the > is getting converted to "&gt;". I am not able to figure out what the problem is. However, the angular brackets in the SOAP header is remaining intact and correct.

Can anyone please help?
Also, the return from the web service being caught in the caller class is getting NULL.


=============WSDL=========================================================================================================
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService" xmlns:intf="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService" xmlns:tns1="http://webservice.check.status.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema targetNamespace="http://webservice.check.status.com" xmlns="http://www.w3.org/2001/XMLSchema">
  </schema>
  <schema targetNamespace="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService" xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="getStatusReturn" type="xsd:anyType"/>
  </schema>
 </wsdl:types>

   <wsdl:message name="getStatusRequest">

      <wsdl:part element="InputCriteria" name="part"/>

   </wsdl:message>

   <wsdl:message name="getStatusResponse">

      <wsdl:part element="impl:getStatusReturn" name="getStatusReturn"/>

   </wsdl:message>

   <wsdl:portType name="VerifyStatusService">

      <wsdl:operation name="getStatus">

         <wsdl:input message="impl:getStatusRequest" name="getStatusRequest"/>

         <wsdl:output message="impl:getStatusResponse" name="getStatusResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="VerifyStatusServiceSoapBinding" type="impl:VerifyStatusService">

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

      <wsdl:operation name="getStatus">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="getStatusRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="getStatusResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="VerifyStatusServiceService">

      <wsdl:port binding="impl:VerifyStatusServiceSoapBinding" name="VerifyStatusService">

         <wsdlsoap:address location="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>
===========================END OF WEB SERVICE==============================================================================


=======================PROXY CLASS DEFINITION==============================================================================

'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.42
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

'
'This source code was auto-generated by wsdl, Version=2.0.50727.42.
'

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"),  _
 System.Diagnostics.DebuggerStepThroughAttribute(),  _
 System.ComponentModel.DesignerCategoryAttribute("code"),  _
 System.Web.Services.WebServiceBindingAttribute(Name:="VerifyStatusServiceSoapBinding", [Namespace]:="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService")>  _
Partial Public Class VerifyStatusServiceService
    Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
    
    Private getStatusOperationCompleted As System.Threading.SendOrPostCallback
    
    '''<remarks/>
    Public Sub New()
        MyBase.New
        Me.Url = "http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService"
        
    End Sub
    
    '''<remarks/>
    Public Event getStatusCompleted As getStatusCompletedEventHandler
    
    '''<remarks/>
    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
      Public Function getStatus(<System.Xml.Serialization.XmlElementAttribute("getStatus", [Namespace]:="http://webservice.check.status.com")> ByVal getStatus1 As Object) As <System.Xml.Serialization.XmlElementAttribute("getStatusReturn", [Namespace]:="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService")> Object
        Dim results() As Object = Me.Invoke("getStatus", New Object() {getStatus1})
        Return CType(results(0), Object)
    End Function
    
    '''<remarks/>
    Public Function BegingetStatus(ByVal getStatus1 As Object, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
        Return Me.BeginInvoke("getStatus", New Object() {getStatus1}, callback, asyncState)
    End Function
    
    '''<remarks/>
    Public Function EndgetStatus(ByVal asyncResult As System.IAsyncResult) As Object
        Dim results() As Object = Me.EndInvoke(asyncResult)
        Return CType(results(0),Object)
    End Function
    
    '''<remarks/>
    Public Overloads Sub getStatusAsync(ByVal getStatus1 As Object)
        Me.getStatusAsync(getStatus1, Nothing)
    End Sub
    
    '''<remarks/>
    Public Overloads Sub getStatusAsync(ByVal getStatus1 As Object, ByVal userState As Object)
        If (Me.getStatusOperationCompleted Is Nothing) Then
            Me.getStatusOperationCompleted = AddressOf Me.OngetStatusOperationCompleted
        End If
        Me.InvokeAsync("getStatus", New Object() {getStatus1}, Me.getStatusOperationCompleted, userState)
    End Sub
    
    Private Sub OngetStatusOperationCompleted(ByVal arg As Object)
        If (Not (Me.getStatusCompletedEvent) Is Nothing) Then
            Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs)
            RaiseEvent getStatusCompleted(Me, New getStatusCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState))
        End If
    End Sub
    
    '''<remarks/>
    Public Shadows Sub CancelAsync(ByVal userState As Object)
        MyBase.CancelAsync(userState)
    End Sub
End Class

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")>  _
Public Delegate Sub getStatusCompletedEventHandler(ByVal sender As Object, ByVal e As getStatusCompletedEventArgs)

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"),  _
 System.Diagnostics.DebuggerStepThroughAttribute(),  _
 System.ComponentModel.DesignerCategoryAttribute("code")>  _
Partial Public Class getStatusCompletedEventArgs
    Inherits System.ComponentModel.AsyncCompletedEventArgs
    
    Private results() As Object
    
    Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
        MyBase.New(exception, cancelled, userState)
        Me.results = results
    End Sub
    
    '''<remarks/>
    Public ReadOnly Property Result() As Object
        Get
            Me.RaiseExceptionIfNecessary
            Return CType(Me.results(0),Object)
        End Get
    End Property
End Class

=========================================END OF PROXY CLASS DEFINITION==================================================


=====================================CODE FOR INVOKING METHOD============================================================
'Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Xml.Serialization
'Imports System.Runtime.Serialization.Formatters.Soap
Imports System.IO
Imports System.Text
Imports System



Public Class Console
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(184, 88)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(88, 40)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        '
        'Console
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Console"
        Me.Text = "Console"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Try

            Dim ghij As New System.Xml.XmlDocument
            ghij.Load("C:\Koushik\CREST\Work\NIVR2\INPUT\PFStest-INP-AAF67-000000001591.xml")

      

             Dim myobj As New PFSAgentLoanStatusServiceService


            a = myobj.getAgentLoanStatus(ghij.OuterXml)
          Catch ex As Exception
            MsgBox(ex.ToString)
            MsgBox(ex.StackTrace)
        End Try

    End Sub
End Class



Reply By: gts Reply Date: 12/7/2006 5:25:23 PM
Hi Koushik,

I wonder if you were able to resolve this problem. I am having a similar problem. Like to know if the problem was at the .net client side or webservice (java) side

Thanks


Go to topic 53354

Return to index page 99
Return to index page 98
Return to index page 97
Return to index page 96
Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90