Webservice call with .NET from Nav: strange error

rspruit
Member Posts: 25
I made a dll (C#) to call a webservice. Also a test client (console app) in C#. Works perfectly. Next I set up a new form to test the dll from Navision 4.00SP2. Automation variable referring to the typelib. So far so good. Running the form I get the message :
"De aanroep van functie AddArticle is mislukt. System.Web.Services gaf de volgende melding:
De server heeft een fout in het protocol veroorzaakt. Section=ResponseStatusLine"
Translated: The call to the function AddArticle failed. Web.Services returned the following description:
The server caused an error in the protocol. Section=ResponseStatusLine"
You guess my question: HEEELP! ;-)
"De aanroep van functie AddArticle is mislukt. System.Web.Services gaf de volgende melding:
De server heeft een fout in het protocol veroorzaakt. Section=ResponseStatusLine"
Translated: The call to the function AddArticle failed. Web.Services returned the following description:
The server caused an error in the protocol. Section=ResponseStatusLine"
You guess my question: HEEELP! ;-)
0
Answers
-
Here the Exception.ToString() output:
System.Net.WebException: De server heeft een fout in het protocol veroorzaakt. Section=ResponseStatusLine
bij System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
bij System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
bij System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
bij LogicsWebService.zdlLogicsWebService.Service.AddArticle(String articleCode, String articleName)
bij LogicsWebService.LogicsWebService.AddArticle(String artCode, String artName)
I use authentication: clsService.Credentials = new System.Net.NetworkCredential(m_userID,m_password);
The authentication works well, cause the first calls from Navision were with a invalid user/pwd and that results in the error "401 - unauthenticated" or something like that.
[edit] Correction on the authentication. If I mess up the login/pwd, I still get the ResponseStatusLine error. But my C# testapp does work fine with the latest webservice dll.[/edit]0 -
Navision code:
IF ISCLEAR(clsWS) THEN
CREATE(clsWS);
clsWS.UserID := uID;//=Text: qqq
clsWS.Password := pwd;//=Text: yyy
iResult := clsWS.AddArticle(artCode,artName); // 2x Text: X and Y, result = Integer
CLEAR(clsWS);
C# code:
public int AddArticle(string artCode,string artName)
{
this.SetCredentials();
try
{
return clsService.AddArticle(artCode,artName);
}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
return -1000;
}
}
C# code part from the Webreference/wsdl.exe:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://LogiqsAgro.com/AddArticle", RequestNamespace="http://LogiqsAgro.com/", ResponseNamespace="http://LogiqsAgro.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int AddArticle(string articleCode, string articleName) {
object[] results = this.Invoke("AddArticle", new object[] {
articleCode,
articleName});
return ((int)(results[0]));
}0 -
If you need more info let me know, I'll post it tomorrow. For now thanks for your help!0
-
Hey BlackTiger, I applied the [...] stuff from your example and it works! But the thing that raises my eyebrows is that the original code also works!
Beats me! Thanks 100x anyway!
One little thing that you might also know: Every time I registered the modified dll I get a new entry in the automation server list in Navision. If I unregister the dll with regasm xxxx.dll /u, the entry is not selectable in Navision, but is still there. I register with regasm xxxx.dll /t. Is it possible to use the same entry over and over?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions