Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2006, 05:28 AM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML tags getting converted during exchange

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?

 
Old October 19th, 2006, 05:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>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
 
Old October 23rd, 2006, 11:26 AM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old October 23rd, 2006, 11:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old October 25th, 2006, 11:37 PM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old October 26th, 2006, 02:19 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Okay, without the WSDL it's hard to help though.

--

Joe (Microsoft MVP - XML)
 
Old October 28th, 2006, 07:30 AM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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("w sdl", "2.0.50727.42"), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("c ode"), _
 System.Web.Services.WebServiceBindingAttribute(Nam e:="VerifyStatusServiceSoapBinding", [Namespace]:="http://localhost:9080/VerifyStatusWeb/webservice/VerifyStatusService")> _
Partial Public Class VerifyStatusServiceService
    Inherits System.Web.Services.Protocols.SoapHttpClientProtoc ol

    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.SoapDocumentMethodA ttribute("", Use:=System.Web.Services.Description.SoapBindingUs e.Literal, ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Bare)> _
      Public Function getStatus(<System.Xml.Serialization.XmlElementAttr ibute("getStatus", [Namespace]:="http://webservice.check.status.com")> ByVal getStatus1 As Object) As <System.Xml.Serialization.XmlElementAttribute("get StatusReturn", [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.InvokeCompletedEvent Args = CType(arg,System.Web.Services.Protocols.InvokeComp letedEventArgs)
            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("w sdl", "2.0.50727.42")> _
Public Delegate Sub getStatusCompletedEventHandler(ByVal sender As Object, ByVal e As getStatusCompletedEventArgs)

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("w sdl", "2.0.50727.42"), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("c ode")> _
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\PFSte st-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



 
Old December 7th, 2006, 06:25 PM
gts gts is offline
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding deleting tags in an xml abhi.prince4u XML 0 July 14th, 2007 12:16 AM
Replacing tags within xml using xslt patelgaurav85 XSLT 0 June 19th, 2007 12:34 PM
Tags as text in XML elements janise XML 16 January 2nd, 2007 06:45 AM
Calling Axis web service from .Net - XML Exchange Koushik .NET Web Services 0 October 23rd, 2006 11:40 AM
Renaming with XML tags? johrik XSLT 1 February 12th, 2004 03:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.