Webservice trouble!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jens Jensen

    #1

    Webservice trouble!


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

    System.Xml.XmlD ocument. 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.Diagnost ics;

    using System.Web.Serv ices;

    using System.Componen tModel;

    using System.Web.Serv ices.Protocols;

    using System;

    using System.Xml.Seri alization;



    /// <remarks/>

    [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    "2.0.50727. 42")]

    [System.Diagnost ics.DebuggerSte pThroughAttribu te()]

    [System.Componen tModel.Designer CategoryAttribu te("code")]

    [System.Web.Serv ices.WebService BindingAttribut e(Name="Service Soap",
    Namespace="http ://tempuri.org/")]

    public partial class Service :
    System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {


    private System.Threadin g.SendOrPostCal lback
    processMessageO perationComplet ed;


    private bool useDefaultCrede ntialsSetExplic itly;


    /// <remarks/>

    public Service() {

    this.Url =
    global::testMyW ebService.Prope rties.Settings. Default.testMyW ebService_local host_Service;

    if ((this.IsLocalF ileSystemWebSer vice(this.Url) == true)) {

    this.UseDefault Credentials = true;

    this.useDefault CredentialsSetE xplicitly = false;

    }

    else {

    this.useDefault CredentialsSetE xplicitly = true;

    }

    }


    public new string Url {

    get {

    return base.Url;

    }

    set {

    if ((((this.IsLoca lFileSystemWebS ervice(base.Url ) == true)

    && (this.useDefaul tCredentialsSet Explicitly == false))

    && (this.IsLocalFi leSystemWebServ ice(value) == false))) {

    base.UseDefault Credentials = false;

    }

    base.Url = value;

    }

    }


    public new bool UseDefaultCrede ntials {

    get {

    return base.UseDefault Credentials;

    }

    set {

    base.UseDefault Credentials = value;

    this.useDefault CredentialsSetE xplicitly = true;

    }

    }


    /// <remarks/>

    public event processMessageC ompletedEventHa ndler processMessageC ompleted;


    /// <remarks/>

    [System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute("h ttp://tempuri.org/processMessage" ,
    RequestNamespac e="http://tempuri.org/",
    ResponseNamespa ce="http://tempuri.org/",
    Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal,
    ParameterStyle= System.Web.Serv ices.Protocols. SoapParameterSt yle.Wrapped)]

    public System.Xml.XmlN ode processMessage( System.Xml.XmlN ode mes) {

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

    mes});

    return ((System.Xml.Xm lNode)(results[0]));

    }


    /// <remarks/>

    public void processMessageA sync(System.Xml .XmlNode mes) {

    this.processMes sageAsync(mes, null);

    }


    /// <remarks/>

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

    if ((this.processM essageOperation Completed == null)) {

    this.processMes sageOperationCo mpleted = new
    System.Threadin g.SendOrPostCal lback(this.Onpr ocessMessageOpe rationCompleted );

    }

    this.InvokeAsyn c("processMessa ge", new object[] {

    mes}, this.processMes sageOperationCo mpleted, userState);

    }


    private void OnprocessMessag eOperationCompl eted(object arg) {

    if ((this.processM essageCompleted != null)) {

    System.Web.Serv ices.Protocols. InvokeCompleted EventArgs invokeArgs =
    ((System.Web.Se rvices.Protocol s.InvokeComplet edEventArgs)(ar g));

    this.processMes sageCompleted(t his, new
    processMessageC ompletedEventAr gs(invokeArgs.R esults, invokeArgs.Erro r,
    invokeArgs.Canc elled, invokeArgs.User State));

    }

    }


    /// <remarks/>

    public new void CancelAsync(obj ect userState) {

    base.CancelAsyn c(userState);

    }


    private bool IsLocalFileSyst emWebService(st ring 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.StringCo mparison.Ordina lIgnoreCase) == 0))) {

    return true;

    }

    return false;

    }

    }


    /// <remarks/>

    [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    "2.0.50727. 42")]

    public delegate void processMessageC ompletedEventHa ndler(object sender,
    processMessageC ompletedEventAr gs e);


    /// <remarks/>

    [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    "2.0.50727. 42")]

    [System.Diagnost ics.DebuggerSte pThroughAttribu te()]

    [System.Componen tModel.Designer CategoryAttribu te("code")]

    public partial class processMessageC ompletedEventAr gs :
    System.Componen tModel.AsyncCom pletedEventArgs {


    private object[] results;


    internal processMessageC ompletedEventAr gs(object[] results, System.Exceptio n
    exception, bool cancelled, object userState) :

    base(exception, cancelled, userState) {

    this.results = results;

    }


    /// <remarks/>

    public System.Xml.XmlN ode Result {

    get {

    this.RaiseExcep tionIfNecessary ();

    return ((System.Xml.Xm lNode)(this.res ults[0]));

    }

    }

    }

    }





    How can i call this webservice with an

    System.Xml.XmlD ocument

    and read the result with

    System.Xml.XmlD ocument

    ?

    I'm using visual studio 2005.



    Many thanks in advance

    JJ


  • Peter Bromberg [C# MVP]

    #2
    RE: Webservice trouble!

    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:

    UnBlog:





    "jens Jensen" wrote:
    [color=blue]
    >
    > Hello,
    > I need to call a webservice with an
    > System.Xml.XmlD ocument objet and read the return value into and
    >
    > System.Xml.XmlD ocument. 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.Diagnost ics;
    >
    > using System.Web.Serv ices;
    >
    > using System.Componen tModel;
    >
    > using System.Web.Serv ices.Protocols;
    >
    > using System;
    >
    > using System.Xml.Seri alization;
    >
    >
    >
    > /// <remarks/>
    >
    > [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    > "2.0.50727. 42")]
    >
    > [System.Diagnost ics.DebuggerSte pThroughAttribu te()]
    >
    > [System.Componen tModel.Designer CategoryAttribu te("code")]
    >
    > [System.Web.Serv ices.WebService BindingAttribut e(Name="Service Soap",
    > Namespace="http ://tempuri.org/")]
    >
    > public partial class Service :
    > System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {
    >
    >
    > private System.Threadin g.SendOrPostCal lback
    > processMessageO perationComplet ed;
    >
    >
    > private bool useDefaultCrede ntialsSetExplic itly;
    >
    >
    > /// <remarks/>
    >
    > public Service() {
    >
    > this.Url =
    > global::testMyW ebService.Prope rties.Settings. Default.testMyW ebService_local host_Service;
    >
    > if ((this.IsLocalF ileSystemWebSer vice(this.Url) == true)) {
    >
    > this.UseDefault Credentials = true;
    >
    > this.useDefault CredentialsSetE xplicitly = false;
    >
    > }
    >
    > else {
    >
    > this.useDefault CredentialsSetE xplicitly = true;
    >
    > }
    >
    > }
    >
    >
    > public new string Url {
    >
    > get {
    >
    > return base.Url;
    >
    > }
    >
    > set {
    >
    > if ((((this.IsLoca lFileSystemWebS ervice(base.Url ) == true)
    >
    > && (this.useDefaul tCredentialsSet Explicitly == false))
    >
    > && (this.IsLocalFi leSystemWebServ ice(value) == false))) {
    >
    > base.UseDefault Credentials = false;
    >
    > }
    >
    > base.Url = value;
    >
    > }
    >
    > }
    >
    >
    > public new bool UseDefaultCrede ntials {
    >
    > get {
    >
    > return base.UseDefault Credentials;
    >
    > }
    >
    > set {
    >
    > base.UseDefault Credentials = value;
    >
    > this.useDefault CredentialsSetE xplicitly = true;
    >
    > }
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > public event processMessageC ompletedEventHa ndler processMessageC ompleted;
    >
    >
    > /// <remarks/>
    >
    > [System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute("h ttp://tempuri.org/processMessage" ,
    > RequestNamespac e="http://tempuri.org/",
    > ResponseNamespa ce="http://tempuri.org/",
    > Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal,
    > ParameterStyle= System.Web.Serv ices.Protocols. SoapParameterSt yle.Wrapped)]
    >
    > public System.Xml.XmlN ode processMessage( System.Xml.XmlN ode mes) {
    >
    > object[] results = this.Invoke("pr ocessMessage", new object[] {
    >
    > mes});
    >
    > return ((System.Xml.Xm lNode)(results[0]));
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > public void processMessageA sync(System.Xml .XmlNode mes) {
    >
    > this.processMes sageAsync(mes, null);
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > public void processMessageA sync(System.Xml .XmlNode mes, object userState) {
    >
    > if ((this.processM essageOperation Completed == null)) {
    >
    > this.processMes sageOperationCo mpleted = new
    > System.Threadin g.SendOrPostCal lback(this.Onpr ocessMessageOpe rationCompleted );
    >
    > }
    >
    > this.InvokeAsyn c("processMessa ge", new object[] {
    >
    > mes}, this.processMes sageOperationCo mpleted, userState);
    >
    > }
    >
    >
    > private void OnprocessMessag eOperationCompl eted(object arg) {
    >
    > if ((this.processM essageCompleted != null)) {
    >
    > System.Web.Serv ices.Protocols. InvokeCompleted EventArgs invokeArgs =
    > ((System.Web.Se rvices.Protocol s.InvokeComplet edEventArgs)(ar g));
    >
    > this.processMes sageCompleted(t his, new
    > processMessageC ompletedEventAr gs(invokeArgs.R esults, invokeArgs.Erro r,
    > invokeArgs.Canc elled, invokeArgs.User State));
    >
    > }
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > public new void CancelAsync(obj ect userState) {
    >
    > base.CancelAsyn c(userState);
    >
    > }
    >
    >
    > private bool IsLocalFileSyst emWebService(st ring 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.StringCo mparison.Ordina lIgnoreCase) == 0))) {
    >
    > return true;
    >
    > }
    >
    > return false;
    >
    > }
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    > "2.0.50727. 42")]
    >
    > public delegate void processMessageC ompletedEventHa ndler(object sender,
    > processMessageC ompletedEventAr gs e);
    >
    >
    > /// <remarks/>
    >
    > [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
    > "2.0.50727. 42")]
    >
    > [System.Diagnost ics.DebuggerSte pThroughAttribu te()]
    >
    > [System.Componen tModel.Designer CategoryAttribu te("code")]
    >
    > public partial class processMessageC ompletedEventAr gs :
    > System.Componen tModel.AsyncCom pletedEventArgs {
    >
    >
    > private object[] results;
    >
    >
    > internal processMessageC ompletedEventAr gs(object[] results, System.Exceptio n
    > exception, bool cancelled, object userState) :
    >
    > base(exception, cancelled, userState) {
    >
    > this.results = results;
    >
    > }
    >
    >
    > /// <remarks/>
    >
    > public System.Xml.XmlN ode Result {
    >
    > get {
    >
    > this.RaiseExcep tionIfNecessary ();
    >
    > return ((System.Xml.Xm lNode)(this.res ults[0]));
    >
    > }
    >
    > }
    >
    > }
    >
    > }
    >
    >
    >
    >
    >
    > How can i call this webservice with an
    >
    > System.Xml.XmlD ocument
    >
    > and read the result with
    >
    > System.Xml.XmlD ocument
    >
    > ?
    >
    > I'm using visual studio 2005.
    >
    >
    >
    > Many thanks in advance
    >
    > JJ
    >
    >[/color]

    Comment

    • jens Jensen

      #3
      Re: Webservice trouble!

      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]" <pbromberg@yaho o.nospammin.com > skrev i en
      meddelelse news:296A1A57-E96A-46CE-A5D8-8E9B62E8B596@mi crosoft.com...[color=blue]
      > 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:
      >[color=green]
      >>
      >> Hello,
      >> I need to call a webservice with an
      >> System.Xml.XmlD ocument objet and read the return value into and
      >>
      >> System.Xml.XmlD ocument. 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.Diagnost ics;
      >>
      >> using System.Web.Serv ices;
      >>
      >> using System.Componen tModel;
      >>
      >> using System.Web.Serv ices.Protocols;
      >>
      >> using System;
      >>
      >> using System.Xml.Seri alization;
      >>
      >>
      >>
      >> /// <remarks/>
      >>
      >> [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
      >> "2.0.50727. 42")]
      >>
      >> [System.Diagnost ics.DebuggerSte pThroughAttribu te()]
      >>
      >> [System.Componen tModel.Designer CategoryAttribu te("code")]
      >>
      >> [System.Web.Serv ices.WebService BindingAttribut e(Name="Service Soap",
      >> Namespace="http ://tempuri.org/")]
      >>
      >> public partial class Service :
      >> System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {
      >>
      >>
      >> private System.Threadin g.SendOrPostCal lback
      >> processMessageO perationComplet ed;
      >>
      >>
      >> private bool useDefaultCrede ntialsSetExplic itly;
      >>
      >>
      >> /// <remarks/>
      >>
      >> public Service() {
      >>
      >> this.Url =
      >> global::testMyW ebService.Prope rties.Settings. Default.testMyW ebService_local host_Service;
      >>
      >> if ((this.IsLocalF ileSystemWebSer vice(this.Url) == true)) {
      >>
      >> this.UseDefault Credentials = true;
      >>
      >> this.useDefault CredentialsSetE xplicitly = false;
      >>
      >> }
      >>
      >> else {
      >>
      >> this.useDefault CredentialsSetE xplicitly = true;
      >>
      >> }
      >>
      >> }
      >>
      >>
      >> public new string Url {
      >>
      >> get {
      >>
      >> return base.Url;
      >>
      >> }
      >>
      >> set {
      >>
      >> if ((((this.IsLoca lFileSystemWebS ervice(base.Url ) == true)
      >>
      >> && (this.useDefaul tCredentialsSet Explicitly == false))
      >>
      >> && (this.IsLocalFi leSystemWebServ ice(value) == false))) {
      >>
      >> base.UseDefault Credentials = false;
      >>
      >> }
      >>
      >> base.Url = value;
      >>
      >> }
      >>
      >> }
      >>
      >>
      >> public new bool UseDefaultCrede ntials {
      >>
      >> get {
      >>
      >> return base.UseDefault Credentials;
      >>
      >> }
      >>
      >> set {
      >>
      >> base.UseDefault Credentials = value;
      >>
      >> this.useDefault CredentialsSetE xplicitly = true;
      >>
      >> }
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> public event processMessageC ompletedEventHa ndler processMessageC ompleted;
      >>
      >>
      >> /// <remarks/>
      >>
      >> [System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute("h ttp://tempuri.org/processMessage" ,
      >> RequestNamespac e="http://tempuri.org/",
      >> ResponseNamespa ce="http://tempuri.org/",
      >> Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal,
      >> ParameterStyle= System.Web.Serv ices.Protocols. SoapParameterSt yle.Wrapped)]
      >>
      >> public System.Xml.XmlN ode processMessage( System.Xml.XmlN ode mes) {
      >>
      >> object[] results = this.Invoke("pr ocessMessage", new object[] {
      >>
      >> mes});
      >>
      >> return ((System.Xml.Xm lNode)(results[0]));
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> public void processMessageA sync(System.Xml .XmlNode mes) {
      >>
      >> this.processMes sageAsync(mes, null);
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> public void processMessageA sync(System.Xml .XmlNode mes, object userState)
      >> {
      >>
      >> if ((this.processM essageOperation Completed == null)) {
      >>
      >> this.processMes sageOperationCo mpleted = new
      >> System.Threadin g.SendOrPostCal lback(this.Onpr ocessMessageOpe rationCompleted );
      >>
      >> }
      >>
      >> this.InvokeAsyn c("processMessa ge", new object[] {
      >>
      >> mes}, this.processMes sageOperationCo mpleted, userState);
      >>
      >> }
      >>
      >>
      >> private void OnprocessMessag eOperationCompl eted(object arg) {
      >>
      >> if ((this.processM essageCompleted != null)) {
      >>
      >> System.Web.Serv ices.Protocols. InvokeCompleted EventArgs invokeArgs =
      >> ((System.Web.Se rvices.Protocol s.InvokeComplet edEventArgs)(ar g));
      >>
      >> this.processMes sageCompleted(t his, new
      >> processMessageC ompletedEventAr gs(invokeArgs.R esults, invokeArgs.Erro r,
      >> invokeArgs.Canc elled, invokeArgs.User State));
      >>
      >> }
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> public new void CancelAsync(obj ect userState) {
      >>
      >> base.CancelAsyn c(userState);
      >>
      >> }
      >>
      >>
      >> private bool IsLocalFileSyst emWebService(st ring 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.StringCo mparison.Ordina lIgnoreCase) == 0))) {
      >>
      >> return true;
      >>
      >> }
      >>
      >> return false;
      >>
      >> }
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
      >> "2.0.50727. 42")]
      >>
      >> public delegate void processMessageC ompletedEventHa ndler(object sender,
      >> processMessageC ompletedEventAr gs e);
      >>
      >>
      >> /// <remarks/>
      >>
      >> [System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Web.S ervices",
      >> "2.0.50727. 42")]
      >>
      >> [System.Diagnost ics.DebuggerSte pThroughAttribu te()]
      >>
      >> [System.Componen tModel.Designer CategoryAttribu te("code")]
      >>
      >> public partial class processMessageC ompletedEventAr gs :
      >> System.Componen tModel.AsyncCom pletedEventArgs {
      >>
      >>
      >> private object[] results;
      >>
      >>
      >> internal processMessageC ompletedEventAr gs(object[] results,
      >> System.Exceptio n
      >> exception, bool cancelled, object userState) :
      >>
      >> base(exception, cancelled, userState) {
      >>
      >> this.results = results;
      >>
      >> }
      >>
      >>
      >> /// <remarks/>
      >>
      >> public System.Xml.XmlN ode Result {
      >>
      >> get {
      >>
      >> this.RaiseExcep tionIfNecessary ();
      >>
      >> return ((System.Xml.Xm lNode)(this.res ults[0]));
      >>
      >> }
      >>
      >> }
      >>
      >> }
      >>
      >> }
      >>
      >>
      >>
      >>
      >>
      >> How can i call this webservice with an
      >>
      >> System.Xml.XmlD ocument
      >>
      >> and read the result with
      >>
      >> System.Xml.XmlD ocument
      >>
      >> ?
      >>
      >> I'm using visual studio 2005.
      >>
      >>
      >>
      >> Many thanks in advance
      >>
      >> JJ
      >>
      >>[/color][/color]


      Comment

      • jens Jensen

        #4
        Re: Webservice trouble!

        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


        Comment

        • Peter Bromberg [C# MVP]

          #5
          Re: Webservice trouble!

          This is where I learned how to do it:

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

          Peter
          --
          Co-founder, Eggheadcafe.com developer portal:

          UnBlog:





          "jens Jensen" wrote:
          [color=blue]
          > 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
          >
          >
          >[/color]

          Comment

          Working...