Preserve whitespace

M

Mike

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("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="svcProvider",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class svcProvider :
System.Web.Services.Protocols.SoapHttpClientProtocol {

public JIHeader JIHeaderValue;

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

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("JIDebugResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public string
JIDebug([System.Xml.Serialization.XmlElementAttribute("JIDebug",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imthExitSuccessOrLockResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthExitSuccessOrLockResponse
imthExitSuccessOrLock([System.Xml.Serialization.XmlElementAttribute("imthExitSuccessOrLock",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imthTimeoutFailureResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthTimeoutFailureResponse
imthTimeoutFailure([System.Xml.Serialization.XmlElementAttribute("imthTimeoutFailure",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("mthAddINProviderResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public mthAddINProviderResponse
mthAddINProvider([System.Xml.Serialization.XmlElementAttribute("mthAddINProvider",
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(Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class mthAddINProviderResponseOutVar_0MthAddINProvider_outputStatus
{

/// <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(Namespace="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(Namespace="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.jacada_statuscode;
}
 
G

Guest

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("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="svcProvider",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class svcProvider :
System.Web.Services.Protocols.SoapHttpClientProtocol {

public JIHeader JIHeaderValue;

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

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("JIDebugResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public string
JIDebug([System.Xml.Serialization.XmlElementAttribute("JIDebug",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imthExitSuccessOrLockResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthExitSuccessOrLockResponse
imthExitSuccessOrLock([System.Xml.Serialization.XmlElementAttribute("imthExitSuccessOrLock",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("imthTimeoutFailureResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public imthTimeoutFailureResponse
imthTimeoutFailure([System.Xml.Serialization.XmlElementAttribute("imthTimeoutFailure",
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.SoapDocumentMethodAttribute("",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("mthAddINProviderResponse",
Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public mthAddINProviderResponse
mthAddINProvider([System.Xml.Serialization.XmlElementAttribute("mthAddINProvider",
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(Namespace="http://svcProvider.wsdlgen.provider.jacada.blah.com")]
public class mthAddINProviderResponseOutVar_0MthAddINProvider_outputStatus
{

/// <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(Namespace="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(Namespace="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.jacada_statuscode;
}



I've the same problem



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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top