0 Replies Latest reply on Jun 4, 2010 8:57 AM by notinuse2010

    Flex + Asp.Net webservice errors

    notinuse2010

      Hi there,

       

      I'm new to Flex but amazed by its capabilities. So, my boss ask me to do a WebSite that will access a SQL server in the client's server.

      I made the webservice in Asp.Net and the flex application and everything went fine on the local machine. Then I put my application in the web and when I access the application it throws me the follow error:

       

      [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://ftpporto.dyndns.org:8080/webservice_VH/Service1.asmx?WSDL)"]
          at mx.rpc.wsdl::WSDLLoader/faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\ rpc\wsdl\WSDLLoader.as:98]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\framewor ks\projects\rpc\src\mx\rpc\AbstractInvoker.as:170]
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\p rojects\rpc\src\mx\rpc\AbstractInvoker.as:225]
          at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder .as:53]
          at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncR equest.as:103]
          at DirectHTTPMessageResponder/securityErrorHandler()[C:\autobuild\3.2.0\frameworks\projects\ rpc\src\mx\messaging\channels\DirectHTTPChannel.as:389]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/redirectEvent()

       

       

      My webservice code is the follow:

       

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.Services;
      using System.Data;
      using System.Data.SqlClient;

       

      namespace WebService_VH
      {
          public class Service1 : System.Web.Services.WebService
          {
              public string str_con = @"Data Source=RICARDO-PC;UID=sa;PWD=ftp;Initial Catalog=maisritmo2010";

       

              [WebMethod]
              public string VerificaUtilizador(string user, string pass, string tipo)
              {
                  string retorna = "false";
                  SqlConnection con = new SqlConnection(str_con);
                  SqlCommand cmd = new SqlCommand();
                  SqlDataReader dr = null;
                  cmd.Connection = con;

       

                  user = RetiraPlicas(user);
                  pass = RetiraPlicas(pass);
                  tipo = RetiraPlicas(tipo);

       

                  try
                  {
                      con.Open();
                      if (tipo.ToLower() == "cliente")
                          cmd.CommandText = "select no,nome from cl where u_user='"+user+"' and u_pass='"+pass+"'";
                      else if (tipo.ToLower() == "funcionário")
                          cmd.CommandText = "select username from us where usercode='"+user+"' and u_pass='"+pass+"'";
                      dr = cmd.ExecuteReader();
                      if (dr.HasRows)
                      {
                          dr.Read();
                          if (tipo.ToLower() == "cliente")
                              retorna = dr["no"].ToString() + ";" + dr["nome"].ToString();
                          else if (tipo.ToLower() == "funcionário")
                              retorna = dr["username"].ToString();
                      }
                      dr.Close();
                      dr.Dispose();
                      con.Close();
                  }
                  catch(Exception ex)
                  {
                      retorna = ex.Message;
                  }          

       

                  return retorna;
              }

       


              public string RetiraPlicas(string valor)
              {
                  if (valor.Contains("'"))
                      valor = valor.Replace("'", "");

       

                  return valor;
              }
          }
      }

       

       

      And the Flex MXML source code is the follow:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" currentState="Login">
          <mx:WebService id="service" wsdl="http://ftpporto.dyndns.org:8080/webservice_VH/Service1.asmx?WSDL" showBusyCursor="true" />
          <mx:states>
              <mx:State name="Login">
                  <mx:SetProperty target="{lbl_titulo}" name="text" value="Área Reservada"/>
                  <mx:SetProperty target="{lbl_titulo}" name="enabled" value="true"/>
                  <mx:SetProperty target="{lbl_titulo}" name="y" value="185"/>
                  <mx:SetStyle target="{lbl_titulo}" name="color" value="#2E356B"/>
                  <mx:SetStyle target="{lbl_titulo}" name="fontWeight" value="normal"/>
                  <mx:AddChild position="lastChild">
                      <mx:Image y="231" horizontalCenter="-1" width="368" height="150" source="../conteudos/imagens/ecra_login.png" id="ecra_login"/>
                  </mx:AddChild>
                  <mx:SetStyle target="{lbl_titulo}" name="horizontalCenter" value="2"/>
                  <mx:AddChild position="lastChild">
                      <mx:Label text="Utilizador" id="lbl_utilizador" enabled="true" fontSize="12" top="253" horizontalCenter="-121"/>
                  </mx:AddChild>
                  <mx:AddChild position="lastChild">
                      <mx:Label text="Password" id="lbl_password" enabled="true" fontSize="12" top="281" horizontalCenter="-123"/>
                  </mx:AddChild>
                  <mx:AddChild position="lastChild">
                      <mx:Label text="Tipo" id="lbl_tipo" enabled="true" fontSize="12" top="309" horizontalCenter="-105"/>
                  </mx:AddChild>
                  <mx:AddChild position="lastChild">
                      <mx:TextInput width="232" id="txt_utilizador" top="250" horizontalCenter="32" themeColor="#CACF2D"/>
                  </mx:AddChild>
                  <mx:AddChild position="lastChild">
                      <mx:TextInput width="232" id="txt_password" top="278" horizontalCenter="32" displayAsPassword="true" editable="true" enabled="true" themeColor="#CACF2D"/>
                  </mx:AddChild>
                  <mx:AddChild position="lastChild">
                      <mx:ComboBox width="232" id="cbox_tipo" top="307" horizontalCenter="32" themeColor="#CACF2D">
                          <mx:dataProvider>
                                <mx:Array>                           
                                   <mx:String>Cliente</mx:String>
                                   <mx:String>Funcionário</mx:String>                            
                                 </mx:Array>
                             </mx:dataProvider>
                      </mx:ComboBox>               
                  </mx:AddChild>
                  <mx:SetProperty name="height" value="100%"/>           
                  <mx:SetProperty target="{rodape}" name="height" value="20"/>
                  <mx:AddChild position="lastChild">
                      <mx:Button y="341" label="Ok" horizontalCenter="103" id="btn_ok" width="90" fillAlphas="[1.0, 1.0]" fillColors="[#CACF2D, #CACF2D, #D4D945, #888C1E]" borderColor="#CACF2D" click="service.VerificaUtilizador(txt_utilizador.text, txt_password.text, cbox_tipo.text)"/>
                  </mx:AddChild>
                  <mx:SetStyle name="themeColor" value="#CACF2D"/>
              </mx:State>
          </mx:states>
          <mx:Image width="900" height="60" horizontalCenter="0" y="0" source="../conteudos/imagens/banner_comlogo.png" id="banner"/>
          <mx:Label y="85" horizontalCenter="9" width="525" textAlign="center" fontSize="26" id="lbl_titulo" enabled="true" color="#2E356B" text="{service.VerificaUtilizador.lastResult}"/>
          <mx:Image horizontalCenter="0" width="900" id="rodape" source="../conteudos/imagens/rodape.png" bottom="0"/>
      </mx:Application>

       

       

      So, Do you know How to solve this problem?

       

      Sorry if this is not the place for this kind of discussions.

       

      Thanks in Advance,

      Ricardo Costa