I Can't Add Web Reference on c# on Visual Studio ?
-
Hi Everybody ,
I Connect XML Api Service On Web Browser and My Username and Password.
But When I Add Web Reference On C# My Username and passwod Not Working (XML Api Services Return 401 Error Code ) and I Can not adding web reference.
anyone know solution this problem.
Please help Me ?
-
Keith Staff
You code is somehow not sending a properly formatted authentication header in the http request.
What warning does it show in the MdMgmtWS logfine when you attempt this?
-
VS Studio Can not add web reference or can not read $metada File
MdMgmWS Logs records
23/05/31 00:00:04.898 General 00000000 Management Web Service (64bit) for MDaemon Messaging Server 23.0.1.2 Log file starting
23/05/31 00:00:04.898 General 00000000 0x41350011 0x00000009
23/05/31 00:00:04.898 General 00000000 0x41350010 D:\MDaemon\Data\MgmtWS.ini
23/05/31 09:23:12.539 Info 0000EE63 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:23:12.539 Warning 0000EE63 0x81420060 HTTP Status: 401
23/05/31 09:23:12.540 Info 0000EE63 0x41420030 Connection terminating
23/05/31 09:23:12.543 Info 0000EE6D 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:23:12.543 Warning 0000EE6D 0x81420060 HTTP Status: 401
23/05/31 09:23:12.543 Info 0000EE6D 0x41420030 Connection terminating
23/05/31 09:23:12.905 Info 0000EE69 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:POST SSL:On UA:(null) QS: Lang:(null) CT=application/soap+xml; charset=utf-8 CL=467
23/05/31 09:23:12.905 Warning 0000EE69 0x81420060 HTTP Status: 401
23/05/31 09:23:12.905 Info 0000EE69 0x41420030 Connection terminating
23/05/31 09:23:12.906 Info 0000EE5F 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:POST SSL:On UA:(null) QS: Lang:(null) CT=application/soap+xml; charset=utf-8 CL=471
23/05/31 09:23:12.906 Warning 0000EE5F 0x81420060 HTTP Status: 401
23/05/31 09:23:12.906 Info 0000EE5F 0x41420030 Connection terminating
23/05/31 09:23:24.583 Info 0000EE77 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:23:24.583 Warning 0000EE77 0x81420060 HTTP Status: 401
23/05/31 09:23:24.584 Info 0000EE77 0x41420030 Connection terminating
23/05/31 09:23:24.625 Info 0000EE7D 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:23:24.777 Info 0000EE7D 0x41330006 Logon Attempt: mehmet.yenilmez@bashan.com.tr
23/05/31 09:23:24.777 Warning 0000EE7D 0x81420060 HTTP Status: 401
23/05/31 09:23:24.777 Info 0000EE7D 0x41420030 Connection terminating
23/05/31 09:24:34.034 Info 0000EE84 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:24:34.034 Warning 0000EE84 0x81420060 HTTP Status: 401
23/05/31 09:24:34.034 Info 0000EE84 0x41420030 Connection terminating
23/05/31 09:24:34.036 Info 0000EE8A 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:24:34.037 Warning 0000EE8A 0x81420060 HTTP Status: 401
23/05/31 09:24:34.037 Info 0000EE8A 0x41420030 Connection terminating
23/05/31 09:24:34.405 Info 0000EE94 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:POST SSL:On UA:(null) QS: Lang:(null) CT=application/soap+xml; charset=utf-8 CL=471
23/05/31 09:24:34.405 Warning 0000EE94 0x81420060 HTTP Status: 401
23/05/31 09:24:34.405 Info 0000EE94 0x41420030 Connection terminating
23/05/31 09:24:34.405 Info 0000EE90 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:POST SSL:On UA:(null) QS: Lang:(null) CT=application/soap+xml; charset=utf-8 CL=467
23/05/31 09:24:34.406 Warning 0000EE90 0x81420060 HTTP Status: 401
23/05/31 09:24:34.406 Info 0000EE90 0x41420030 Connection terminating
23/05/31 09:24:48.815 Info 0000EE9C 0x41330080 Connection: IPA:10.0.1.126 Server:ms01 Meth:GET SSL:On UA:Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000) QS: Lang:(null) CT= CL=0
23/05/31 09:24:48.815 Warning 0000EE9C 0x81420060 HTTP Status: 401
23/05/31 09:24:48.815 Info 0000EE9C 0x41420030 Connection terminating
-
Keith Staff
I am not familiar with adding a "Web Reference", however, the XMLAPI uses Basic authentication, always.
First, unrelated to the 401 you are receiving, is that the content-type header on any post operations should be set to text/xml, not application/soap+xml
Regarding the 401, all POST and GET requests require a properly formatted Basic Authentication header. There could be a number of possible issues with your request...
- You might not be sending an Authorization Header with Basic and a properly base64 encoded logon and password
- You might be sending an Authorization Header but the authentication type is not set to Basic
- You might be sending an Authorization Header with Basic and the logon and password are not properly Base64 encoded or not present
- You might be sending an Authorization Header with Basic and the encoded auth information does not contain a colon ":" to separate the logon and password.
- You might be sending an Authorization Header with Basic and encoded auth information has no characters prior to the first colon character, hance, it has an empty logon name.
- You might be sending an Authorization Header with Basic and encoded auth information there are no characters following the first colon character, hence, an empty password value.
- The logon name specified does not include a domain and your MD settings require that you use the full email address for logons.
- You might be attempting to log on with an alias, and your MD settings do not allow that.
- The domain that you are using in your logon is disabled
Have you inspected the Authorization header that your client is sending?
-
Dear Keith ,
I Try SoapUi And I Send Basic Auth. And I Give Error
Error Message:
Error : WSDLException (at /MDaemon): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'
I try Many Difrent program to connect web XML Api But Result is all negative.
Can you share if you have any running programs and settings?
-
Keith Staff
The Samples in the Help portal (via web browser) list Powershell and Windows Script (JavaScript) files that contain functional code.
- DSAddBlackItem.wsf
- DSWhiteListReport.wsf
- FolderOperationGetContacts.wsf
- FolderOperation_create_delete.wsf
- GetDomainList.wsf
- Common.js
- ActiveSyncAlterLogEntries.ps1
- ActiveSyncDisable.ps1
- ActiveSyncEnable.ps1
- ActiveSyncGetClients.ps1
- ActiveSyncGetConfiguration.ps1
- ActiveSyncGetDomain.ps1
- ActiveSyncGetGlobal.ps1
- ActiveSyncSetLogLevelDebug.ps1
- ActiveSyncSetProcessDump.ps1
- CreateUserSample.ps1
- DSWhiteListReport.ps1
- GetVersionInfo.ps1
-
Hi Keith , I Know This Samples its Working.
But I Need Use This XML Api .Net Framework Project or .NET Core Project
This XML Api is not useable For VS And SoapUI .
VS and SoapUI Can Not Read Definitions and MetaData
Can This Api working Restful Mode ?
-
Keith Staff
There is currently no support for WSDL. At this time, none is planned, though we may consider it in the future.
I've written several WIN32 utilities in C++ that call the XMLAPI using the WinHttp API (native Win32, not .Net) and not having a WSDL does not preclude one from calling the API in C#, it merely means that you can't depend on Visual Studio to generate code for you.
-
Hello, let's see if I can provide some clarity. I have it working in C#. The issue is that you have to create the classes to deserialize the information. If you are familiar with the C# language, here is a function to test the XML.
I had a similar problem in my early stages with the API, and I have resolved it. I'm sharing the code snippet with you so that you can analyze it.
var httpClient = new HttpClient();
var byteArray = new UTF8Encoding().GetBytes($"{configuracion.adminEmail}:{configuracion.adminPassword}");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
var productValue = new ProductInfoHeaderValue("CommTool", "1.0");
httpClient.DefaultRequestHeaders.UserAgent.Add(productValue);
var stringContent = new StringContent(xmlText, Encoding.UTF8, "application/xml");
var xml = new StringContent(xmlText, Encoding.UTF8, "text/xml");
var respone = await httpClient.PostAsync($"{configuracion.url}", xml);
var test = respone.StatusCode;
var contents = await respone.Content.ReadAsStringAsync();if (respone.StatusCode == HttpStatusCode.OK)
{
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(contents);response(doc: xdoc);
XmlNodeList elemList = xdoc.GetElementsByTagName("Record");
if (configuracion.Debug)
{
log.Debug($"--------------------- Ejecuntando el modulo: XMLTest --------------------------");
log.Debug($"{PrintXML(contents.ToString())}");
}return contents.ToString();
hope it helps you.
-
Hi Javier ,
Thank You For Helping , I Use This Code its Working Thank You.
Now it's Time to Create MDAEMON Objects from XML Files For C#
Have any Idea ?
Let's Go..