Question regarding defaultEditingContext with WebServices
Question regarding defaultEditingContext with WebServices
- Subject: Question regarding defaultEditingContext with WebServices
- From: Davindra Singh <email@hidden>
- Date: Thu, 26 Jun 2003 18:34:13 -0700
Hey guys, I'm new to the mailing list and WebObjects in general.
I have a quick question regarding Web Services.
I have 2 simple applications. One is a WebObjects Web Service, and the other is a WebObjects Client app that uses the Web Service.
Basically I have an EOModel with a users entity (username, password, email address). The Client application feeds in 3 strings to the Web Service, which then creates an instance of a user, populates the users fields, and then dumps it to the database.
Ive done a similar project like this before using one application and no Web Service and it worked fine. I used the sessions defaultEditingContext (with a fetch specification to ensure I dont add a user if its already in the db), and then created an instance of the user object. I then populated the fields with the functions EOModeler generates, and then added the object to the EditingContext. I then saved the changes on the EditingContext, which in turn saved the data to the database.
This was all fine and dandy while it was in one project but when I tried to split it into two, and have the Web Service enter the data into the database I ran into errors.
First thing I did was created a separate class file that would manage all input to and from the database. I registered this class with WOWebServiceRegistrar and its working fine.
I can pass in arguments and return results. However I cant add stuff to the database. When I created the WebService I wasnt able to get access to the defaultEditingContext. Usually I just call this.session().defaultEditingContext(), but I wasnt even able to compile it that way. I tried several things, such as declaring an instance of the class in the session, and passing in the defaultEditingContext. That compiled, but the EditingContext within the class was null (like it was a new instance of the class or something). I also tried declaring a new EditingContext, and that worked, but whenever I tried to save the EditingContext it would always throw an exception.
My question is this: Is there a way to get the default EditingContext in a WebService, and how do I go about doing that? If I cannot, is there a way to create a new EditingContext that is bound to the same Database as the default one?
Thanks very much in advance.
-Dave
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.