WebService c# OTRS Integration

Moderator: crythias

Post Reply
rafaelsmartins
OTRS newbie
Posts: 3
Joined: 04 Apr 2018, 12:35
OTRS Version?: 6.0.6

WebService c# OTRS Integration

Post by rafaelsmartins » 05 Apr 2018, 12:13

Hi,
I'm developing a client software in windows forms c# that retrieves a config item providing his ID.
The webservice responses great and give me the information that i need only in debugger, however the c# application triggers a error:

in this line var response = httpWebReq.GetResponse();
'The underlying connection was closed: The connection was closed unexpectedly.'

here is my code:

var uri = new Uri("http://localhost/otrs/nph-genericinterf ... vice/teste");
var httpWebReq = (HttpWebRequest)WebRequest.CreateDefault(uri);
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
httpWebReq.ProtocolVersion = HttpVersion.Version10; // fix 1
httpWebReq.KeepAlive = false; // fix 2
httpWebReq.Timeout = 1000000000; // fix 3
httpWebReq.ReadWriteTimeout = 1000000000;
httpWebReq.KeepAlive = true;
string Path = @"some path file";
var bytePostData = File.ReadAllBytes(Path);
httpWebReq.Timeout = 5 * 1000;
httpWebReq.Method = "POST";
httpWebReq.ContentLength = bytePostData.Length;
httpWebReq.ContentType = "text/xml;charset=utf-8";
//httpWebReq.TransferEncoding=
//httpWebReq.ContentType = "application/xml";
//httpWebReq.Accept = "application/xml";
var dataStream = httpWebReq.GetRequestStream();

dataStream.Write(bytePostData, 0, bytePostData.Length);
dataStream.Close();
var response = httpWebReq.GetResponse();
hope guys u can help me.
Sorry my English

lido
OTRS expert
Posts: 70
Joined: 25 Oct 2017, 16:21
OTRS Version?: 6.0.5

Re: WebService c# OTRS Integration

Post by lido » 05 Apr 2018, 18:17

I doubt that's an OTRS issue. Anyway, you should check your webserver and otrs log files when trying to access the service and see if there is any useful information about the issue there.

That also seems to be a relatively common issue in c# as seen here, here and here.

Post Reply