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?
– Tobias Mesquita
enter here please: http://chat.stackexchange.com/rooms/20863/discussion-between-war-lock-and-tobymosque
– War Lock
firewall does not allow chat Urls'.
– Tobias Mesquita
put the Exception
– War Lock
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?
– Tobias Mesquita
System.Nullreferenceexception: Undefined object reference for an instance of an object.
– War Lock
file has several attributes, but only set one, has something bird?
– War Lock
Let’s go continue this discussion in chat.
– War Lock
only if you are accessing some File or File Type property or method.
– Tobias Mesquita
then what can it be?
– War Lock
Are you having some difficulty debugging the webservice?
– Tobias Mesquita
The webservice I think is correct, it was someone else who implemented,to making only the client.
– War Lock
Then you will have to do with this person.
– Tobias Mesquita
Did you see the error I commented on? System.Nullreferenceexception: Undefined object reference for an instance of an object
– War Lock
Now you have this error: Error adding file:System.Unauthorizedaccessexception: Access to path 'C: Users user Documents Visual Studio 2012 Client' has been denied.
– War Lock
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?
– War Lock