Consume file sending service

Asked

Viewed 85 times

0

I have basically a c# service that was made to receive a file, what I want is to use this service, I created an Asp.net page with a fileUpluod, and I wanted to put it to work, as I do?

Class of Service:

  public class UpluodService : System.Web.Services.WebService
{

    [WebMethod(Description = "Adiciona um arquivo")]
    public void AddArquivo(Autenticacao autenticacao,Arquivo arquivo)
    {
        Autenticar(autenticacao);
        ArquivoController.GetInstance().AddArquivo(arquivo);



    }

public class Autenticacao
{
    public string Usuario { get; set; }
    public string Senha { get; set; }
}

File class:

 public class Arquivo
{
    public Arquivo() 
    {
        ArquivoVersoes = new List<ArquivoVersao>();
    }
    public string ARQUIVO_GUID { get; set; }
    public string XARQUIVO { get; set; }
    public string TAG { get; set; }
    public string EXTENSAO { get; set; }
    public string URL { get; set; }
    public bool IS_STREAM { get; set; }
    public string ULT_ARQUIVO_VERSAO_GUID { get; set; }
    public string TIPO_DE_ARQUIVO_GUID { get; set; }
    public string DIRETORIO_GUID { get; set; }
    public TipoDeArquivo TipoDeArquivo { get; set; }
    public List<ArquivoVersao> ArquivoVersoes { get; set; } 
}

what I did was try for the event to send, pass the file see:

 protected void btnUpluod_Click(object sender, EventArgs e)
    {
        try
        {
           UpluodService teste = new UpluodService();
            Autenticacao autenticacao = new Autenticacao();
            Arquivo arq = new Arquivo();
            autenticacao.Usuario = "joao";
            autenticacao.Senha = "123456";
            fileUpluod.SaveAs(Server.MapPath("Files") + "//" + fileUpluod.FileName);
            arq.XARQUIVO = fileUpluod.FileName;
            ged.AddArquivo(autenticacao, arq);
            Response.Write("Enviado com sucesso!!!");
        }
        catch (Exception ex)
        {
            Response.Write("Não foi possivel enviar!!!");
            throw new GEDServiceException("Erro ao enviar arquivo");
        }
    }

I tried that way , but he always falls in the catch, and I can not identify the error, but I know that must be wrong this implementation, who can help thank.

Exception:

 System.Exception was unhandled by user code
 HResult=-2146233088
 Message=Erro ao adicionar arquivo
 Source=Cliente
 StackTrace:
   em Cliente._Default.buttonEnviar_Click(Object sender, EventArgs e) na           em   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   em System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   em  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   em System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   em System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   em System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Innerexception:

  • could place the Exception so we can analyze?

  • enter here please: http://chat.stackexchange.com/rooms/20863/discussion-between-war-lock-and-tobymosque

  • firewall does not allow chat Urls'.

  • put the Exception

  • I believe the error is happening inside the webservice, possibly in the method in the method call . Addfile(file). you can get the real exception generated in the webservice?

  • System.Nullreferenceexception: Undefined object reference for an instance of an object.

  • file has several attributes, but only set one, has something bird?

  • only if you are accessing some File or File Type property or method.

  • then what can it be?

  • Are you having some difficulty debugging the webservice?

  • The webservice I think is correct, it was someone else who implemented,to making only the client.

  • Then you will have to do with this person.

  • Did you see the error I commented on? System.Nullreferenceexception: Undefined object reference for an instance of an object

  • Now you have this error: Error adding file:System.Unauthorizedaccessexception: Access to path 'C: Users user Documents Visual Studio 2012 Client' has been denied.

  • A doubt, if I’m on another project, and import a service the authentication password has to stay on the client’s web.config, or service?

Show 11 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.