f3661

Hi,

I'm running into a problem using web service tech.

I have 2 methods published as AddCustomer and AddSales on the web (web service). Those 2 methods will add a record on table Customer and table Sales respectively. Table Sales has reference to the table Customer (CustomerId).

Now if I called the 2 method with this order:

1. AddCustomer

2. AddSales

It works because the customer is already added to the table Customer and no referential error when the method AddSales invoked.

But when calling these methods, with the above order, simultaneously it generates referential error. For example, I call these methods from 2 different computer continuously.

Can anyone help me with this


Regards


Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

avaya12

You have 2 choices either combine the above methods into a single method or when calling AddCustomer ensure that the customer id is returned from the AddCustomer method. You then use this id when creating the AddSales call. That way you ensure the the customer has been created before the sales item.

Just a side note its not really a good design to model web service calls after CRUD.




Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

f3661

I'm aware of those solution, but what happened I mean is this behaviour normal Because the two methods was called synchronuously.


And btw, the case was simple test case, my application requires calling web services in synchronuous way, and not CRUD btw.

Another example perhaps an online banking application. The first method was to deposit some money, the second was to withdraw money. If this behaviour is normal then web service is not suitable for this kind of application, because if the withdraw money is called before the deposit one then it will fail in some point.




Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

avaya12

The solution you describe is not normal have you put a trace on the database to try and see what is happening or maybe some sort of logging at the web service level. Web services should not be designed at the level described in your banking example. It makes more sense to have a transfer funds web service which does both the deposit/withdraw funtionality as web services do not provide support for things like 2 phase commits as a database would.

CRUD referes to modelling web services after database like calls e.g. insertCustomer, UpdateCustomer it has nothing to do with being synchronous or asynchonous check out the following document

http://msdn2.microsoft.com/en-us/library/ms954638.aspx






Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

Daniel Roth

Messages sent to a web service are fundamentally asynchronous. For two clients sending separate messages to the same service you really have no guarantee on the order that the messages will get processed. You can partially deal with the problem by writing error handling code (ex try again if you couldn't add a sales report for a customer).

Note that you can add support for transactions and reliable messaging with message ordering using the WS-* protocols which are implemented by WCF in .NET 3.0.

http://msdn2.microsoft.com/en-us/library/ms733103.aspx

Daniel Roth






Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

f3661

I'm not questioning about the callings order of two clients, but 2 clients making 2 method calls. I believe that .Net generates two kind of method call to ws, async and sync. I used the sync one.

So the question is, is it normal to have 2 clients, each calling 2 method call sequentially, but the server somehow sometimes retrieves the calls the reverse order. This has never happenned with only 1 client.

I'm trying to narrow down the possibilities, because it's the web service or the database. The client application is straight forward calling those 2 methods so I don't think it's the client application:

proxy.AddCustomer(customer);
proxy.AddSales(sales);





Re: ASMX Web Services and XML Serialization Web Service Flow Control Between Calls

Daniel Roth

A synchronous web service call using an ASMX proxy will block until the service has received the request message and the proxy has received the response message.

So, if you have two client applications and you know that both are making synchronous calls and you know that the first call completes before the second call is made, then you know that the service will receive the requests in order.

I hope this helps.

Daniel Roth