Web Service - Parameter in method is null

Troubles_In_Paradise
Member Posts: 588
Hi guys, I ask your help for a problem with Web Service (this is the first time I use Web Service :oops:).
1. I created a simple CU that receives, as a parameter, the customer code and returns the Entry No. of the last Customer Ledger Entry for this customer.
2. I exposed it as WS (following is the code of this CU):
http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/ and
viewtopic.php?t=39037
but the error is always the same: parametro is null...
has anyone got an idea?
Thx in advance!
1. I created a simple CU that receives, as a parameter, the customer code and returns the Entry No. of the last Customer Ledger Entry for this customer.
2. I exposed it as WS (following is the code of this CU):
ExitLastCustomer(parametro : Text[30]) : Integer CLEAR(Customer); Customer.RESET; Customer.SETRANGE("Customer No.",parametro); Customer.FINDLAST; EXIT(Customer."Entry No.");3. I created a CU that should consume this WS
IF ISCLEAR(XMLDoc) THEN CREATE(XMLDoc); XMLDoc.async := FALSE; XMLDoc.load('C:\Input2.xml'); IF ISCLEAR(XMLHttp) THEN CREATE(XMLHttp); XMLHttp.open('POST','http://localhost:7047/DynamicsNAV/WS/Riktest/Codeunit/ExitLastCustomerWSName',0); XMLHttp.setRequestHeader('Content-type','text/xml'); XMLHttp.setRequestHeader('SOAPAction','ExitLastCustomer'); XMLHttp.send(XMLDoc); XMLDoc.load(XMLHttp.responseXML); XMLDoc.save('C:\temp.xml'); XMLDoc.load(XMLHttp.responseBody); XMLNode := XMLDoc.selectSingleNode('//Soap:Envelope/Soap:Body/ExitLastCustomer_Result/return_value/'); MESSAGE(XMLNode.text);this is the Input2.xml file
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:nav="urn:microsoft-dynamics-schemas/codeunit/NAVWebServices" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header/> <soap:Body> <nav:ExitLastCustomer> <nav:parametro>10000</nav:parametro> </nav:ExitLastCustomer> </soap:Body> </soap:Envelope>to do what I did I followed this links:
http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/ and
viewtopic.php?t=39037
but the error is always the same: parametro is null...
has anyone got an idea?
Thx in advance!
~Rik~
It works as expected... More or Less...
It works as expected... More or Less...
0
Answers
-
Hi Rik,
You create below method in your codeunit (as web service).
ExitLastCustomer(parametro : Text[30]) : Integer
When you are using this web service you must pass the parameters for the method.
e.g. C# .net code
Testcodeunit Service_Testcodeunit = new Testcodeunit();
Service_Testcodeunit.UseDefaultCredentials = true;
Service_Testcodeunit.Url = sNAV_DT_RDNPath.Trim() + "/Codeunit/Testcodeunit";
Service_Testcodeunit.ExitLastCustomer('100000000');0 -
Troubles In Paradise wrote:
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:nav="urn:microsoft-dynamics-schemas/codeunit/NAVWebServices" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header/> <soap:Body> <nav:ExitLastCustomer> <nav:parametro>10000</nav:parametro> </nav:ExitLastCustomer> </soap:Body> </soap:Envelope>
If you read the previous peace of code you can see that I try to pass a value to parametro...~Rik~
It works as expected... More or Less...0 -
Solved, modifing the Input2.xml file as follow
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:nav="urn:microsoft-dynamics-schemas/codeunit/ExitLastCustomerWSName"' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <nav:ExitLastCustomer> <nav:parametro>919</nav:parametro> </nav:ExitLastCustomer> </soap:Body> </soap:Envelope>
~Rik~
It works as expected... More or Less...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