C# Client

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
jcosta
Posts: 6
Joined: Sat Sep 13, 2014 2:53 am

C# Client

Post by jcosta »

Hello!

I'm using Zimbra C# Client located at SourceForge.net Repository - [zimbra] Index of /trunk/ZimbraCSharpClient.
I've tried to login with administrator and didn't work. With a simple user didn't work too. The only response that i get is the HTML of the login page...

I searched internet and didn't found noting.
SOAP MESSAGE:

http://www.w3.org/2003/05/soap-envelope'>











@USERNAME

@PASSWORD






TEST CODE:

string soapMessage = SoapMessageBuilder(message, param);

XmlDocument requestDoc = new XmlDocument();

requestDoc.LoadXml(soapMessage);

HttpWebRequest request = HttpWebRequestBuilder(http://@MYURL/");

Stream stm = request.GetRequestStream();

requestDoc.Save(stm);

stm.Close();

WebResponse resp = request.GetResponse();

stm = resp.GetResponseStream();

StreamReader r = new StreamReader(stm);

XmlDocument responseDoc = new XmlDocument();

responseDoc.LoadXml(r.ReadToEnd());
"r.ReadToEnd()" returns HTML login page.
Am i doing anything wrong?
Thanks in advanced!
13445raj
Outstanding Member
Outstanding Member
Posts: 743
Joined: Fri Sep 12, 2014 9:59 pm
Location: Canada
Contact:

C# Client

Post by 13445raj »

probably your (http://@MYURL/") is wrong

it should be


you">https://YOUR_ZIMBRA_SERVER:7071/service/admin/soap/
you may also need to handle the self signed SSL cert wraning/exception in your code
Raj
jcosta
Posts: 6
Joined: Sat Sep 13, 2014 2:53 am

C# Client

Post by jcosta »

Thank you very much for your reply!

Ok so i modified the url but still got an error: "The remote server returned an error: (500) Internal Server Error.".

Forgot to mention in the first post a method: "HttpWebRequestBuilder". In this method i've swicth the value between "retVal.Headers.Add("SOAPAction", """");" and "retVal.Headers.Add("SOAPAction", "urn:zimbraAdmin");" but still doesn't work.


SOAP MESSAGE:

http://www.w3.org/2003/05/soap-envelope'>











@USER

@PASS






TEST CODE:

private static HttpWebRequest HttpWebRequestBuilder(string serviceAdminSoapUri)

{

HttpWebRequest retVal = (HttpWebRequest)WebRequest.Create(serviceAdminSoapUri);

//retVal.Headers.Add("SOAPAction", """");

retVal.Headers.Add("SOAPAction", "urn:zimbraAdmin");

retVal.ContentType = "text/xml;charset="utf-8"";

retVal.Accept = "text/xml";

retVal.Method = "POST";

return retVal;

}

string soapMessage = SoapMessageBuilder(message, param);

XmlDocument requestDoc = new XmlDocument();

requestDoc.LoadXml(soapMessage);

HttpWebRequest request = HttpWebRequestBuilder(https://@MYZIMBRASERVER:7071/service/admin/soap");

Stream stm = request.GetRequestStream();

requestDoc.Save(stm);

stm.Close();

WebResponse resp = request.GetResponse();

stm = resp.GetResponseStream();

StreamReader r = new StreamReader(stm);

XmlDocument responseDoc = new XmlDocument();

responseDoc.LoadXml(r.ReadToEnd());

return responseDoc;
Thanks in advanced!
jcosta
Posts: 6
Joined: Sat Sep 13, 2014 2:53 am

C# Client

Post by jcosta »

Apparently i was using the wrong @USER.

Thanks for the help!
Post Reply