Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Preserve whitespace

Reply
Thread Tools

Preserve whitespace

 
 
Mike
Guest
Posts: n/a
 
      09-29-2004
Hi,
I am consuming a web service in my asp.net application. I added the
web references in Visual Studio by pointing to a wsdl file. Visual
Studio automatically creates the Reference.cs file and the code that
is used to serialize the classes used in the server's service. I
create an instance of the input variable, set my values, and pass it
to a method. The class is serialized/deserialized for me into an XML
string that is sent to the server. Pretty easy using Visual Studio.

This is all great except that I want to preserve spaces that I pass to
the web service. If I set a public variable in the input class to a
space (" "), the space will be stripped out when the serialization
takes place.

How do I edit the Reference.cs file to change this behavior? Or, can
this be defined in the wsdl file so that as I refresh my Web Reference
in Visual Studio, I will not have to make the change each time. Is
there a way to globally set preserve xml:space="preserve" for all of
my input classes?

Here is a chunk of my Reference.cs file and the code that actually
makes the method call. (although I do not think you need this)
Can someone show me how to alter it to make my resulting xml contain a
xml:space="preserve" tag?
Thanks,
Mike


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

//
// This source code was auto-generated by Microsoft.VSDesigner,
Version 1.1.4322.573.
//
namespace MHS.jacada {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;


/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="svcProvider",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class svcProvider :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

public JIHeader JIHeaderValue;

/// <remarks/>
public svcProvider() {
this.Url = "http://blah:8080/JIWSVC/services/svcProvider";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("JIDe bugResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public string
JIDebug([System.Xml.Serialization.XmlElementAttribute("JIDe bug",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
JIDebug JIDebug1) {
object[] results = this.Invoke("JIDebug", new object[] {
JIDebug1});
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginJIDebug(JIDebug JIDebug1,
System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("JIDebug", new object[] {
JIDebug1}, callback, asyncState);
}

/// <remarks/>
public string EndJIDebug(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imth ExitSuccessOrLockResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthExitSuccessOrLockResponse
imthExitSuccessOrLock([System.Xml.Serialization.XmlElementAttribute("imth ExitSuccessOrLock",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
imthExitSuccessOrLock imthExitSuccessOrLock1) {
object[] results = this.Invoke("imthExitSuccessOrLock",
new object[] {
imthExitSuccessOrLock1});
return ((imthExitSuccessOrLockResponse)(results[0]));
}

/// <remarks/>
public System.IAsyncResult
BeginimthExitSuccessOrLock(imthExitSuccessOrLock
imthExitSuccessOrLock1, System.AsyncCallback callback, object
asyncState) {
return this.BeginInvoke("imthExitSuccessOrLock", new
object[] {
imthExitSuccessOrLock1}, callback,
asyncState);
}

/// <remarks/>
public imthExitSuccessOrLockResponse
EndimthExitSuccessOrLock(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((imthExitSuccessOrLockResponse)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imth TimeoutFailureResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthTimeoutFailureResponse
imthTimeoutFailure([System.Xml.Serialization.XmlElementAttribute("imth TimeoutFailure",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
imthTimeoutFailure imthTimeoutFailure1) {
object[] results = this.Invoke("imthTimeoutFailure", new
object[] {
imthTimeoutFailure1});
return ((imthTimeoutFailureResponse)(results[0]));
}

/// <remarks/>
public System.IAsyncResult
BeginimthTimeoutFailure(imthTimeoutFailure imthTimeoutFailure1,
System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("imthTimeoutFailure", new object[]
{
imthTimeoutFailure1}, callback, asyncState);
}

/// <remarks/>
public imthTimeoutFailureResponse
EndimthTimeoutFailure(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((imthTimeoutFailureResponse)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("mthA ddINProviderResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public mthAddINProviderResponse
mthAddINProvider([System.Xml.Serialization.XmlElementAttribute("mthA ddINProvider",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
mthAddINProvider mthAddINProvider1) {
object[] results = this.Invoke("mthAddINProvider", new
object[] {
mthAddINProvider1});
return ((mthAddINProviderResponse)(results[0]));
}


/// <remarks/>
public System.IAsyncResult
BeginmthAddINProvider(mthAddINProvider mthAddINProvider1,
System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("mthAddINProvider", new object[] {
mthAddINProvider1}, callback, asyncState);
}

/// <remarks/>
public mthAddINProviderResponse
EndmthAddINProvider(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((mthAddINProviderResponse)(results[0]));
}

}

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class mthAddINProviderResponseOutVar_0MthAddINProvider_o utputStatus
{

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string host_message;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string jacada_statuscode;
}



/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class mthAddINProviderInVar_0 {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public mthAddINProviderInVar_0MthAddINProvider_input
mthAddINProvider_input;
}




/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class mthAddINProviderInVar_0MthAddINProvider_input {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string input_a;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string input_b;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string input_c;

}
}

--------------- end of Reference.cs ------------------


public string Add()
{
MHS.jacada.mthAddINProvider input = new
MHS.jacada.mthAddINProvider();
MHS.jacada.mthAddINProviderInVar_0 inVar = new
MHS.jacada.mthAddINProviderInVar_0();
MHS.jacada.mthAddINProviderInVar_0MthAddINProvider _input inVarInput =
new MHS.jacada.mthAddINProviderInVar_0MthAddINProvider _input();
// sure wish these spaces were preserved!
inVarInput.input_a = " y ";
inVarInput.input_a = " ";
inVarInput.input_a = " ";
inVar.mthAddINProvider_input = inVarInput;
input.InVar_0 = inVar;
MHS.jacada.mthAddINProviderResponse output =
jacadaService.mthAddINProvider( input );
return output.OutVar_0.mthAddINProvider_output.Status.jac ada_statuscode;
}
 
Reply With Quote
 
 
 
 
Guest
Guest
Posts: n/a
 
      04-21-2005


> Hi,
> I am consuming a web service in my asp.net application. I added the
> web references in Visual Studio by pointing to a wsdl file. Visual
> Studio automatically creates the Reference.cs file and the code that
> is used to serialize the classes used in the server's service. I
> create an instance of the input variable, set my values, and pass it
> to a method. The class is serialized/deserialized for me into an XML
> string that is sent to the server. Pretty easy using Visual Studio.
>
> This is all great except that I want to preserve spaces that I pass to
> the web service. If I set a public variable in the input class to a
> space (" "), the space will be stripped out when the serialization
> takes place.
>
> How do I edit the Reference.cs file to change this behavior? Or, can
> this be defined in the wsdl file so that as I refresh my Web Reference
> in Visual Studio, I will not have to make the change each time. Is
> there a way to globally set preserve xml:space="preserve" for all of
> my input classes?
>
> Here is a chunk of my Reference.cs file and the code that actually
> makes the method call. (although I do not think you need this)
> Can someone show me how to alter it to make my resulting xml contain a
> xml:space="preserve" tag?
> Thanks,
> Mike
>
>
> //------------------------------------------------------------------------------
> // <autogenerated>
> // This code was generated by a tool.
> // Runtime Version: 1.1.4322.573
> //
> // Changes to this file may cause incorrect behavior and will be
> lost if
> // the code is regenerated.
> // </autogenerated>
> //------------------------------------------------------------------------------
>
> //
> // This source code was auto-generated by Microsoft.VSDesigner,
> Version 1.1.4322.573.
> //
> namespace MHS.jacada {
> using System.Diagnostics;
> using System.Xml.Serialization;
> using System;
> using System.Web.Services.Protocols;
> using System.ComponentModel;
> using System.Web.Services;
>
>
> /// <remarks/>
> [System.Diagnostics.DebuggerStepThroughAttribute()]
> [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> [System.Web.Services.WebServiceBindingAttribute(Nam e="svcProvider",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public class svcProvider :
> System.Web.Services.Protocols.SoapHttpClientProtoc ol {
>
> public JIHeader JIHeaderValue;
>
> /// <remarks/>
> public svcProvider() {
> this.Url = "http://blah:8080/JIWSVC/services/svcProvider";
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
> [return: System.Xml.Serialization.XmlElementAttribute("JIDe bugResponse",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public string
> JIDebug([System.Xml.Serialization.XmlElementAttribute("JIDe bug",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> JIDebug JIDebug1) {
> object[] results = this.Invoke("JIDebug", new object[] {
> JIDebug1});
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> public System.IAsyncResult BeginJIDebug(JIDebug JIDebug1,
> System.AsyncCallback callback, object asyncState) {
> return this.BeginInvoke("JIDebug", new object[] {
> JIDebug1}, callback, asyncState);
> }
>
> /// <remarks/>
> public string EndJIDebug(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
> [return: System.Xml.Serialization.XmlElementAttribute("imth ExitSuccessOrLockResponse",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public imthExitSuccessOrLockResponse
> imthExitSuccessOrLock([System.Xml.Serialization.XmlElementAttribute("imth ExitSuccessOrLock",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> imthExitSuccessOrLock imthExitSuccessOrLock1) {
> object[] results = this.Invoke("imthExitSuccessOrLock",
> new object[] {
> imthExitSuccessOrLock1});
> return ((imthExitSuccessOrLockResponse)(results[0]));
> }
>
> /// <remarks/>
> public System.IAsyncResult
> BeginimthExitSuccessOrLock(imthExitSuccessOrLock
> imthExitSuccessOrLock1, System.AsyncCallback callback, object
> asyncState) {
> return this.BeginInvoke("imthExitSuccessOrLock", new
> object[] {
> imthExitSuccessOrLock1}, callback,
> asyncState);
> }
>
> /// <remarks/>
> public imthExitSuccessOrLockResponse
> EndimthExitSuccessOrLock(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((imthExitSuccessOrLockResponse)(results[0]));
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
> [return: System.Xml.Serialization.XmlElementAttribute("imth TimeoutFailureResponse",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public imthTimeoutFailureResponse
> imthTimeoutFailure([System.Xml.Serialization.XmlElementAttribute("imth TimeoutFailure",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> imthTimeoutFailure imthTimeoutFailure1) {
> object[] results = this.Invoke("imthTimeoutFailure", new
> object[] {
> imthTimeoutFailure1});
> return ((imthTimeoutFailureResponse)(results[0]));
> }
>
> /// <remarks/>
> public System.IAsyncResult
> BeginimthTimeoutFailure(imthTimeoutFailure imthTimeoutFailure1,
> System.AsyncCallback callback, object asyncState) {
> return this.BeginInvoke("imthTimeoutFailure", new object[]
> {
> imthTimeoutFailure1}, callback, asyncState);
> }
>
> /// <remarks/>
> public imthTimeoutFailureResponse
> EndimthTimeoutFailure(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((imthTimeoutFailureResponse)(results[0]));
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "JIHeaderValue")]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
> [return: System.Xml.Serialization.XmlElementAttribute("mthA ddINProviderResponse",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public mthAddINProviderResponse
> mthAddINProvider([System.Xml.Serialization.XmlElementAttribute("mthA ddINProvider",
> Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> mthAddINProvider mthAddINProvider1) {
> object[] results = this.Invoke("mthAddINProvider", new
> object[] {
> mthAddINProvider1});
> return ((mthAddINProviderResponse)(results[0]));
> }
>
>
> /// <remarks/>
> public System.IAsyncResult
> BeginmthAddINProvider(mthAddINProvider mthAddINProvider1,
> System.AsyncCallback callback, object asyncState) {
> return this.BeginInvoke("mthAddINProvider", new object[] {
> mthAddINProvider1}, callback, asyncState);
> }
>
> /// <remarks/>
> public mthAddINProviderResponse
> EndmthAddINProvider(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((mthAddINProviderResponse)(results[0]));
> }
>
> }
>
> /// <remarks/>
> [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public class mthAddINProviderResponseOutVar_0MthAddINProvider_o utputStatus
> {
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string host_message;
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string jacada_statuscode;
> }
>
>
>
> /// <remarks/>
> [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public class mthAddINProviderInVar_0 {
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public mthAddINProviderInVar_0MthAddINProvider_input
> mthAddINProvider_input;
> }
>
>
>
>
> /// <remarks/>
> [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
> public class mthAddINProviderInVar_0MthAddINProvider_input {
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string input_a;
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string input_b;
>
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string input_c;
>
> }
> }
>
> --------------- end of Reference.cs ------------------
>
>
> public string Add()
> {
> MHS.jacada.mthAddINProvider input = new
> MHS.jacada.mthAddINProvider();
> MHS.jacada.mthAddINProviderInVar_0 inVar = new
> MHS.jacada.mthAddINProviderInVar_0();
> MHS.jacada.mthAddINProviderInVar_0MthAddINProvider _input inVarInput =
> new MHS.jacada.mthAddINProviderInVar_0MthAddINProvider _input();
> // sure wish these spaces were preserved!
> inVarInput.input_a = " y ";
> inVarInput.input_a = " ";
> inVarInput.input_a = " ";
> inVar.mthAddINProvider_input = inVarInput;
> input.InVar_0 = inVar;
> MHS.jacada.mthAddINProviderResponse output =
> jacadaService.mthAddINProvider( input );
> return output.OutVar_0.mthAddINProvider_output.Status.jac ada_statuscode;
> }




I've the same problem



User submitted from AEWNET (http://www.aewnet.com/)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Split String Function - How to preserve whitespace? daftspaniel@gmail.com Python 2 07-08-2006 08:07 PM
unable to preserve whitespace soup_or_power@yahoo.com XML 1 05-19-2006 02:02 AM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM
Use of ASP.NET control does not preserve whitespace. Brian W ASP .Net 11 11-14-2003 10:42 PM
FileUtils - :preserve does not preserve mtime of directories on Windoze Grzegorz Chrupala Ruby 2 06-30-2003 07:38 AM



Advertisments