Webservice trouble!

J

jens Jensen

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("System.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtocol {


private System.Threading.SendOrPostCallback
processMessageOperationCompleted;


private bool useDefaultCredentialsSetExplicitly;


/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Default.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.SoapDocumentMethodAttribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.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.OnprocessMessageOperationCompleted);

}

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

mes}, this.processMessageOperationCompleted, userState);

}


private void OnprocessMessageOperationCompleted(object arg) {

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

System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Results, 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("System.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);


/// <remarks/>

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

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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
 
G

Guest

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 said:
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("System.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtocol {


private System.Threading.SendOrPostCallback
processMessageOperationCompleted;


private bool useDefaultCredentialsSetExplicitly;


/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Default.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.SoapDocumentMethodAttribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.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.OnprocessMessageOperationCompleted);

}

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

mes}, this.processMessageOperationCompleted, userState);

}


private void OnprocessMessageOperationCompleted(object arg) {

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

System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Results, 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("System.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);


/// <remarks/>

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

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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
 
J

jens Jensen

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 said:
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 said:
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("System.Web.Services",
"2.0.50727.42")]

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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

public partial class Service :
System.Web.Services.Protocols.SoapHttpClientProtocol {


private System.Threading.SendOrPostCallback
processMessageOperationCompleted;


private bool useDefaultCredentialsSetExplicitly;


/// <remarks/>

public Service() {

this.Url =
global::testMyWebService.Properties.Settings.Default.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.SoapDocumentMethodAttribute("http://tempuri.org/processMessage",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.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.OnprocessMessageOperationCompleted);

}

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

mes}, this.processMessageOperationCompleted, userState);

}


private void OnprocessMessageOperationCompleted(object arg) {

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

System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));

this.processMessageCompleted(this, new
processMessageCompletedEventArgs(invokeArgs.Results, 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("System.Web.Services",
"2.0.50727.42")]

public delegate void processMessageCompletedEventHandler(object sender,
processMessageCompletedEventArgs e);


/// <remarks/>

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

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

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
 
J

jens Jensen

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
 

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

Top