WebService Integration - Web Site >> NAV 2009 R2

I am pushing data from a web site into a NAV table which contains validation/business logic, hence the decision to use the ‘page’ webservice.

So far so good…the create and update functions are working fine. However, this requires two calls in order to insert one record. This becomes inefficient for large volumes of data. The CreateMultiple/UpdateMultiple function is not workable as it is an all or nothing option (i.e if one record fails in 5000 all 5000 will be rejected)

There is also a need to capture the end result - fail or success.

Two Questions:
1- Does NAV web service return a status code to know if the transaction fails or succeeds (instead of working with exceptions)
2- Is there another service method that does the insert & modify (all in one) rather than doing 2 calls (Create then Update)

Help!!!

  1. The service returns the created object so if it fails the object will be nil. If it fails, a message is returned that describes why it failed. (see first soap message below)

  2. Why do you feel that you need to do a create and update. I have run into that when dealing with a document page (like sales order), but for card / list pages you should be able to do the create in one call. Soap message 2 below shows the request and response for the create in the Job Journal. Notice the field values for cost and price are not sent in the request. Then look at the response (the created Job Journal record), notice in the response that NAV functionality populated the correct cost / price fields.

  3. Soap Message that returns an error message:

<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>

<s:Body>

<s:Fault>

a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException

Parameter No is empty

Parameter No is empty

</s:Fault>

</s:Body></s:Envelope>

  1. Soap request to create a record in Job Journal
<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>

soapenv:Body

TIMEENTRY

Resource

true

<Line_Type>Both_Schedule_and_Contract</Line_Type>

<Unit_of_Measure_Code>HOUR</Unit_of_Measure_Code>

<Job_No>GUILDFORD, 10 CR</Job_No>

Get owners approval on wall hangings

0.5

<Document_Date>2011-10-06</Document_Date>

MARY

<Job_Task_No>1130</Job_Task_No>

</soapenv:Body>

</soapenv:Envelope>0

  1. Soap Response from Create message sent

<Soap:Envelope xmlns:Soap=“http://schemas.xmlsoap.org/soap/envelope/”>
Soap:Body
<Create_Result xmlns=“urn:microsoft-dynamics-schemas/page/jobjournal”>

40;0gAAAACJ/0pPQgAAif9USU1FRU5UUlkAAIcgTg==6;2700660;
<Line_Type>Both_Schedule_and_Contract</Line_Type>
<Posting_Date>2011-01-27</Posting_Date>
<Document_Date>2011-10-06</Document_Date>
<Document_No>AAA</Document_No>
<Job_No>GUILDFORD, 10 CR</Job_No>
<Job_Task_No>1130</Job_Task_No>
Resource
MARY
true
Get owners approval on wall hangings
<Gen_Prod_Posting_Group>SERVICES</Gen_Prod_Posting_Group>
<Unit_of_Measure_Code>HOUR</Unit_of_Measure_Code>
0.5
<Direct_Unit_Cost_LCY>76</Direct_Unit_Cost_LCY>
<Unit_Cost>83.6</Unit_Cost>
<Unit_Cost_LCY>83.6</Unit_Cost_LCY>
<Total_Cost>41.8</Total_Cost>
<Total_Cost_LCY>41.8</Total_Cost_LCY>
<Unit_Price>154.1</Unit_Price>
<Unit_Price_LCY>154.1</Unit_Price_LCY>
<Line_Amount>77.05</Line_Amount>
<Line_Amount_LCY>77.05</Line_Amount_LCY>
<Line_Discount_Amount>0</Line_Discount_Amount>
<Line_Discount_Percent>0</Line_Discount_Percent>
<Total_Price>77.05</Total_Price>
<Total_Price_LCY>77.05</Total_Price_LCY>
<Applies_to_Entry>0</Applies_to_Entry>
<Applies_from_Entry>0</Applies_from_Entry>
<Country_Region_Code>US</Country_Region_Code>

</Create_Result>
</Soap:Body></Soap:Envelope>

“1- Does NAV web service return a status code to know if the transaction fails or succeeds (instead of working with exceptions)”
Unfortunately not… You will need to do a try-catch like mechanism to handle the exceptions.

“2- Is there another service method that does the insert & modify (all in one) rather than doing 2 calls (Create then Update)”
No, but depending on what it is you want to do, you do not always have to do 2 roundtrips to the server for inserting.
Take a look at Freddy’s example here with sales lines, where he 1. Creates the Sales Header, then 2. creates all the lines, and finally 3. updates all the lines.
http://blogs.msdn.com/b/freddyk/archive/2009/05/28/handling-sales-orders-from-page-based-web-services-in-nav-2009sp1-and-rtm.aspx

Hope it helps :slight_smile:

Hi Soren,

You are absolutely correct.

I am also using NAV web service in C#.net application to integrate eCommerce data to Navision. we can do error handling in integration application.