By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Webservice trouble!

P: n/a

Hello,
I need to call a webservice with an
System.Xml.XmlDocument objet and read the return value into and

System.Xml.XmlDocument. The webservice was written with an oracle tool and
wrapped into a .net webservice.

I have added a reference to my dotnet wrapper and i get the following
refrence file:
using System.Diagnostics;

using System.Web.Services;

using System.ComponentModel;

using System.Web.Services.Protocols;

using System;

using System.Xml.Serialization;

/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="ServiceSoap",
Namespace="http://tempuri.org/")]

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
private System.Threading.SendOrPostCallback
processMessageOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Defau lt.testMyWebService_localhost_Service;

if ((this.IsLocalFileSystemWebService(this.Url) == true)) {

this.UseDefaultCredentials = true;

this.useDefaultCredentialsSetExplicitly = false;

}

else {

this.useDefaultCredentialsSetExplicitly = true;

}

}
public new string Url {

get {

return base.Url;

}

set {

if ((((this.IsLocalFileSystemWebService(base.Url) == true)

&& (this.useDefaultCredentialsSetExplicitly == false))

&& (this.IsLocalFileSystemWebService(value) == false))) {

base.UseDefaultCredentials = false;

}

base.Url = value;

}

}
public new bool UseDefaultCredentials {

get {

return base.UseDefaultCredentials;

}

set {

base.UseDefaultCredentials = value;

this.useDefaultCredentialsSetExplicitly = true;

}

}
/// <remarks/>

public event processMessageCompletedEventHandler processMessageCompleted;
/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]

public System.Xml.XmlNode processMessage(System.Xml.XmlNode mes) {

object[] results = this.Invoke("processMessage", new object[] {

mes});

return ((System.Xml.XmlNode)(results[0]));

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes) {

this.processMessageAsync(mes, null);

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes, object userState) {

if ((this.processMessageOperationCompleted == null)) {

this.processMessageOperationCompleted = new
System.Threading.SendOrPostCallback(this.Onprocess MessageOperationCompleted);

}

this.InvokeAsync("processMessage", new object[] {

mes}, this.processMessageOperationCompleted, userState);

}
private void OnprocessMessageOperationCompleted(object arg) {

if ((this.processMessageCompleted != null)) {

System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Result s, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));

}

}
/// <remarks/>

public new void CancelAsync(object userState) {

base.CancelAsync(userState);

}
private bool IsLocalFileSystemWebService(string url) {

if (((url == null)

|| (url == string.Empty))) {

return false;

}

System.Uri wsUri = new System.Uri(url);

if (((wsUri.Port >= 1024)

&& (string.Compare(wsUri.Host, "localHost",
System.StringComparison.OrdinalIgnoreCase) == 0))) {

return true;

}

return false;

}

}
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

public partial class processMessageCompletedEventArgs :
System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal processMessageCompletedEventArgs(object[] results, System.Exception
exception, bool cancelled, object userState) :

base(exception, cancelled, userState) {

this.results = results;

}
/// <remarks/>

public System.Xml.XmlNode Result {

get {

this.RaiseExceptionIfNecessary();

return ((System.Xml.XmlNode)(this.results[0]));

}

}

}

}

How can i call this webservice with an

System.Xml.XmlDocument

and read the result with

System.Xml.XmlDocument

?

I'm using visual studio 2005.

Many thanks in advance

JJ
Feb 15 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
JJ,
I have noticed that attempting to return an XmlDocument from an ASP.NET
Webservice usually results in getting an XmlNode. So you can try getting the
result of the WebService Call as XmlNode, and if you really require a
complete XmlDocument, just add the Node to a new instance of XmlDocument.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jens Jensen" wrote:

Hello,
I need to call a webservice with an
System.Xml.XmlDocument objet and read the return value into and

System.Xml.XmlDocument. The webservice was written with an oracle tool and
wrapped into a .net webservice.

I have added a reference to my dotnet wrapper and i get the following
refrence file:
using System.Diagnostics;

using System.Web.Services;

using System.ComponentModel;

using System.Web.Services.Protocols;

using System;

using System.Xml.Serialization;

/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="ServiceSoap",
Namespace="http://tempuri.org/")]

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
private System.Threading.SendOrPostCallback
processMessageOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Defau lt.testMyWebService_localhost_Service;

if ((this.IsLocalFileSystemWebService(this.Url) == true)) {

this.UseDefaultCredentials = true;

this.useDefaultCredentialsSetExplicitly = false;

}

else {

this.useDefaultCredentialsSetExplicitly = true;

}

}
public new string Url {

get {

return base.Url;

}

set {

if ((((this.IsLocalFileSystemWebService(base.Url) == true)

&& (this.useDefaultCredentialsSetExplicitly == false))

&& (this.IsLocalFileSystemWebService(value) == false))) {

base.UseDefaultCredentials = false;

}

base.Url = value;

}

}
public new bool UseDefaultCredentials {

get {

return base.UseDefaultCredentials;

}

set {

base.UseDefaultCredentials = value;

this.useDefaultCredentialsSetExplicitly = true;

}

}
/// <remarks/>

public event processMessageCompletedEventHandler processMessageCompleted;
/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]

public System.Xml.XmlNode processMessage(System.Xml.XmlNode mes) {

object[] results = this.Invoke("processMessage", new object[] {

mes});

return ((System.Xml.XmlNode)(results[0]));

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes) {

this.processMessageAsync(mes, null);

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes, object userState) {

if ((this.processMessageOperationCompleted == null)) {

this.processMessageOperationCompleted = new
System.Threading.SendOrPostCallback(this.Onprocess MessageOperationCompleted);

}

this.InvokeAsync("processMessage", new object[] {

mes}, this.processMessageOperationCompleted, userState);

}
private void OnprocessMessageOperationCompleted(object arg) {

if ((this.processMessageCompleted != null)) {

System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Result s, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));

}

}
/// <remarks/>

public new void CancelAsync(object userState) {

base.CancelAsync(userState);

}
private bool IsLocalFileSystemWebService(string url) {

if (((url == null)

|| (url == string.Empty))) {

return false;

}

System.Uri wsUri = new System.Uri(url);

if (((wsUri.Port >= 1024)

&& (string.Compare(wsUri.Host, "localHost",
System.StringComparison.OrdinalIgnoreCase) == 0))) {

return true;

}

return false;

}

}
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

public partial class processMessageCompletedEventArgs :
System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal processMessageCompletedEventArgs(object[] results, System.Exception
exception, bool cancelled, object userState) :

base(exception, cancelled, userState) {

this.results = results;

}
/// <remarks/>

public System.Xml.XmlNode Result {

get {

this.RaiseExceptionIfNecessary();

return ((System.Xml.XmlNode)(this.results[0]));

}

}

}

}

How can i call this webservice with an

System.Xml.XmlDocument

and read the result with

System.Xml.XmlDocument

?

I'm using visual studio 2005.

Many thanks in advance

JJ

Feb 15 '06 #2

P: n/a
Many thanks Peter,
Well i was very unsure how to go from XmlNode to XmlDocument.
I have now been through a couple msdn pages and it now makes more sens to me
thanks to your posting.

JJ

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> skrev i en
meddelelse news:29**********************************@microsof t.com...
JJ,
I have noticed that attempting to return an XmlDocument from an ASP.NET
Webservice usually results in getting an XmlNode. So you can try getting
the
result of the WebService Call as XmlNode, and if you really require a
complete XmlDocument, just add the Node to a new instance of XmlDocument.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jens Jensen" wrote:

Hello,
I need to call a webservice with an
System.Xml.XmlDocument objet and read the return value into and

System.Xml.XmlDocument. The webservice was written with an oracle tool
and
wrapped into a .net webservice.

I have added a reference to my dotnet wrapper and i get the following
refrence file:
using System.Diagnostics;

using System.Web.Services;

using System.ComponentModel;

using System.Web.Services.Protocols;

using System;

using System.Xml.Serialization;

/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="ServiceSoap",
Namespace="http://tempuri.org/")]

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
private System.Threading.SendOrPostCallback
processMessageOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Defau lt.testMyWebService_localhost_Service;

if ((this.IsLocalFileSystemWebService(this.Url) == true)) {

this.UseDefaultCredentials = true;

this.useDefaultCredentialsSetExplicitly = false;

}

else {

this.useDefaultCredentialsSetExplicitly = true;

}

}
public new string Url {

get {

return base.Url;

}

set {

if ((((this.IsLocalFileSystemWebService(base.Url) == true)

&& (this.useDefaultCredentialsSetExplicitly == false))

&& (this.IsLocalFileSystemWebService(value) == false))) {

base.UseDefaultCredentials = false;

}

base.Url = value;

}

}
public new bool UseDefaultCredentials {

get {

return base.UseDefaultCredentials;

}

set {

base.UseDefaultCredentials = value;

this.useDefaultCredentialsSetExplicitly = true;

}

}
/// <remarks/>

public event processMessageCompletedEventHandler processMessageCompleted;
/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]

public System.Xml.XmlNode processMessage(System.Xml.XmlNode mes) {

object[] results = this.Invoke("processMessage", new object[] {

mes});

return ((System.Xml.XmlNode)(results[0]));

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes) {

this.processMessageAsync(mes, null);

}
/// <remarks/>

public void processMessageAsync(System.Xml.XmlNode mes, object userState)
{

if ((this.processMessageOperationCompleted == null)) {

this.processMessageOperationCompleted = new
System.Threading.SendOrPostCallback(this.Onprocess MessageOperationCompleted);

}

this.InvokeAsync("processMessage", new object[] {

mes}, this.processMessageOperationCompleted, userState);

}
private void OnprocessMessageOperationCompleted(object arg) {

if ((this.processMessageCompleted != null)) {

System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Result s, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));

}

}
/// <remarks/>

public new void CancelAsync(object userState) {

base.CancelAsync(userState);

}
private bool IsLocalFileSystemWebService(string url) {

if (((url == null)

|| (url == string.Empty))) {

return false;

}

System.Uri wsUri = new System.Uri(url);

if (((wsUri.Port >= 1024)

&& (string.Compare(wsUri.Host, "localHost",
System.StringComparison.OrdinalIgnoreCase) == 0))) {

return true;

}

return false;

}

}
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);
/// <remarks/>

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

public partial class processMessageCompletedEventArgs :
System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal processMessageCompletedEventArgs(object[] results,
System.Exception
exception, bool cancelled, object userState) :

base(exception, cancelled, userState) {

this.results = results;

}
/// <remarks/>

public System.Xml.XmlNode Result {

get {

this.RaiseExceptionIfNecessary();

return ((System.Xml.XmlNode)(this.results[0]));

}

}

}

}

How can i call this webservice with an

System.Xml.XmlDocument

and read the result with

System.Xml.XmlDocument

?

I'm using visual studio 2005.

Many thanks in advance

JJ

Feb 16 '06 #3

P: n/a
Hi Peter,
Could you please give a code example. I understand the idea but i haven't
found the right code yet.
Many thanks in advance
JJ
Feb 16 '06 #4

P: n/a
This is where I learned how to do it:

http://msdn.microsoft.com/library/de...tnodetopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"jens Jensen" wrote:
Hi Peter,
Could you please give a code example. I understand the idea but i haven't
found the right code yet.
Many thanks in advance
JJ

Feb 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.