Mensaje dentro de Servicios Webs

Responder 
#1 - 01/08/2013 0:36:53 Reporta abuso | Link Permanente
eldavan
Fecha de registro: 01/08/2013
0 post en este tema
1 post en servicios webs
1 post en todos los foros
Publicar Web Service : Error de conexion

Responder Citar

Saludos cordiales,
Es la primera vez que escribo en este foro, estoy tratando de publicar unservicio web y no he podido, es por eso que estoy acudiendo a ustedes.

 

Al Grano:

Estos con los archivos de mi servicioweb.

Web.config

<?xml version="1.0"?>

 

<configuration

    <appSettings/>

  <connectionStrings>

    <add name="coneactividades"connectionString="server=localhost;port=3306;User Id=aaa;password='wwwwxxw';database=nombd"providerName="MySql.Data.MySqlClient"/>

  </connectionStrings>

    <system.web>

        <compilation debug="false">

 

        </compilation>

        <authentication mode="Windows" />

    </system.web>

  <system.webServer>

    <defaultDocument>

      <files>

        <clear />

        <add value="Service1.asmx" />

 

      </files>

    </defaultDocument>

  </system.webServer>

</configuration>

 

Service1.asmx

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

 

using MySql.Data.MySqlClient;

using System.Configuration;

namespace WebServicesql

{

    /// <summary>

    /// Summary description for Service1

    /// </summary>

    [WebService(Namespace = "http://pagina.com.pe/servicios/Service1.asmx")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [ToolboxItem(false)]

    public class Service1 : System.Web.Services.WebService

    {

 

        [WebMethod]

        public DataSet listas()

        {

            string value1 = string.Empty;

            string value2 = string.Empty;

 

            MySqlConnection conn = newMySqlConnection(ConfigurationManager.AppSettings["coneactividades"].ToString());

            DataSet DSdataset = new DataSet();

            conn.Open();

            MySqlDataAdapter Query = new MySqlDataAdapter("Select apellidocontac,nombrecontac fromcliente", conn);

            Query.Fill(DSdataset, "Data");

 

            if (DSdataset.Tables[0].Rows.Count > 0)

            {

                return DSdataset;

            }

            else {

                return null;

            }

            conn.Close();

        }

       

        [WebMethod]

        public string HelloWorld()

        {

            return "Hello World";

        }

    }

}

 

 

 

===========================
y estos son los archivos del cliente

Form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using ejm11.avastw;

namespace ejm11

{

    public partial class Form1 : Form

    {

        Service1 sc = new Service1();

        private void button1_Click(object sender, EventArgs e)

        {

            try

            {

                label1.Text= sc.HelloWorld();

 

                DataSet d = new DataSet();

                d= sc.listas();

                dataGridView1.DataSource= d;

            }

            catch (Exception x)

            {

                textBox1.Text= x.Message;

            }

        }

 

        public Form1()

        {

            InitializeComponent();

        }

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

//------------------------------------------------------------------------------

//<auto-generated>

//     This code was generated by a tool.

//     Runtime Version:2.0.50727.5466

//

//     Changes to this file may cause incorrectbehavior and will be lost if

//     the code is regenerated.

//</auto-generated>

//------------------------------------------------------------------------------

 

//

// This sourcecode was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.5466.

//

#pragma warningdisable 1591

 

namespaceejm11.avastw {

    usingSystem.Diagnostics;

    usingSystem.Web.Services;

    usingSystem.ComponentModel;

    usingSystem.Web.Services.Protocols;

    usingSystem;

    usingSystem.Xml.Serialization;

    usingSystem.Data;

   

   

    /// <remarks/>

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

    [System.Diagnostics.DebuggerStepThroughAttribute()]

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

    [System.Web.Services.WebServiceBindingAttribute(Name="Service1Soap", Namespace="http:// pagina.com.pe/servicios/Service1.asmx")]

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

       

        privateSystem.Threading.SendOrPostCallbacklistasOperationCompleted;

       

        privateSystem.Threading.SendOrPostCallbackHelloWorldOperationCompleted;

       

        privatebool useDefaultCredentialsSetExplicitly;

       

        /// <remarks/>

        publicService1() {

            this.Url= global::ejm11.Properties.Settings.Default.ejm11_avastw_Service1;

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

                this.UseDefaultCredentials= true;

                this.useDefaultCredentialsSetExplicitly= false;

            }

            else{

                this.useDefaultCredentialsSetExplicitly= true;

            }

        }

       

        public new string Url {

            get{

                returnbase.Url;

            }

            set{

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

                            && (this.useDefaultCredentialsSetExplicitly == false))

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

                    base.UseDefaultCredentials= false;

                }

                base.Url= value;

            }

        }

       

        public new boolUseDefaultCredentials {

            get{

                returnbase.UseDefaultCredentials;

            }

            set{

                base.UseDefaultCredentials= value;

                this.useDefaultCredentialsSetExplicitly= true;

            }

        }

       

        /// <remarks/>

        public event listasCompletedEventHandlerlistasCompleted;

       

        /// <remarks/>

        public event HelloWorldCompletedEventHandlerHelloWorldCompleted;

       

        /// <remarks/>

        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http:// pagina.com.pe/servicios/Service1.asmx/listas",RequestNamespace="http:// pagina.com.pe/servicios/Service1.asmx",ResponseNamespace="http:// pagina.com.pe/servicios/Service1.asmx",Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

        publicSystem.Data.DataSet listas() {

            object[]results = this.Invoke("listas",new object[0]);

            return((System.Data.DataSet)(results[0]));

        }

       

        /// <remarks/>

        public void listasAsync() {

            this.listasAsync(null);

        }

       

        /// <remarks/>

        public void listasAsync(objectuserState) {

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

                this.listasOperationCompleted= new System.Threading.SendOrPostCallback(this.OnlistasOperationCompleted);

            }

            this.InvokeAsync("listas", newobject[0], this.listasOperationCompleted,userState);

        }

       

        privatevoid OnlistasOperationCompleted(object arg) {

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

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

                this.listasCompleted(this, new listasCompletedEventArgs(invokeArgs.Results,invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));

            }

        }

       

        /// <remarks/>

        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http:// pagina.com.pe/servicios/Service1.asmx/HelloWorld",RequestNamespace="http:// pagina.com.pe/servicios/Service1.asmx",ResponseNamespace="http:// pagina.com.pe/servicios/Service1.asmx",Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

        public string HelloWorld() {

            object[]results = this.Invoke("HelloWorld",new object[0]);

            return((string)(results[0]));

        }

       

        /// <remarks/>

        public void HelloWorldAsync() {

            this.HelloWorldAsync(null);

        }

       

        /// <remarks/>

        public void HelloWorldAsync(objectuserState) {

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

                this.HelloWorldOperationCompleted= new System.Threading.SendOrPostCallback(this.OnHelloWorldOperationCompleted);

            }

            this.InvokeAsync("HelloWorld", newobject[0], this.HelloWorldOperationCompleted,userState);

        }

       

        privatevoid OnHelloWorldOperationCompleted(object arg) {

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

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

                this.HelloWorldCompleted(this, new HelloWorldCompletedEventArgs(invokeArgs.Results,invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));

            }

        }

       

        /// <remarks/>

        public new void CancelAsync(objectuserState) {

            base.CancelAsync(userState);

        }

       

        privatebool IsLocalFileSystemWebService(string url) {

            if(((url == null)

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

                returnfalse;

            }

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

            if(((wsUri.Port >= 1024)

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

                returntrue;

            }

            returnfalse;

        }

    }

   

    /// <remarks/>

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

    public delegate void listasCompletedEventHandler(object sender, listasCompletedEventArgse);

   

    /// <remarks/>

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

    [System.Diagnostics.DebuggerStepThroughAttribute()]

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

    public partial class listasCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {

       

        privateobject[] results;

       

        internallistasCompletedEventArgs(object[] results,System.Exception exception, bool cancelled, objectuserState) :

                base(exception,cancelled, userState) {

            this.results= results;

        }

       

        /// <remarks/>

        publicSystem.Data.DataSet Result {

            get{

                this.RaiseExceptionIfNecessary();

                return((System.Data.DataSet)(this.results[0]));

            }

        }

    }

   

    /// <remarks/>

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

    public delegate void HelloWorldCompletedEventHandler(object sender, HelloWorldCompletedEventArgse);

   

    /// <remarks/>

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

    [System.Diagnostics.DebuggerStepThroughAttribute()]

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

    public partial class HelloWorldCompletedEventArgs :System.ComponentModel.AsyncCompletedEventArgs{

       

        privateobject[] results;

       

        internalHelloWorldCompletedEventArgs(object[] results,System.Exception exception, bool cancelled, objectuserState) :

                base(exception,cancelled, userState) {

            this.results= results;

        }

       

        /// <remarks/>

        public string Result {

            get{

                this.RaiseExceptionIfNecessary();

                return((string)(this.results[0]));

            }

        }

    }

}

 

#pragma warning restore 1591

 

Cuando ejecuto el codigo (en el cliente) tengoeste error

En esta linea    private void button1_Click(object sender, EventArgs e)

        {

label1.Text = sc.HelloWorld();

 

                DataSetd = new DataSet();

                d = sc.listas();

               dataGridView1.DataSource = d;
}

---------------------------

Microsoft VisualStudio

---------------------------

Unable toautomatically step into the server. Connecting to the server machine 'avast.comtel.com.pe'failed. Logon failure: unknown user name or bad password. See help for moreinformation.

---------------------------

Aceptar   Ayuda  

A que puede deberse esto?

Cuál es mi error.

Gracias por su apoyo

Volver arriba