New Posts New Posts RSS Feed: Problem adding a web service to the domain model
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Problem adding a web service to the domain model

 Post Reply Post Reply Page  12>
Author
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Topic: Problem adding a web service to the domain model
    Posted: 06-Nov-2009 at 4:47pm

Are there any samples of a project that has a web service
added to the domain model?  When I try that with my local
web service (exposed by the same ASP.NET project) I get
this error message from the Object Mapper:
"Unable to add web service: Could not find the file
'M:\ ...(detail removed)...
\PrismExplorer\ModelExplorer.Explorer\ServiceReference3.edmx'"

Any idea why the Object Mapper thinks I should have a *.EDMX
corresponding to the web service I'm trying to add?

BTW: The Dev Guide (p128 about "Mapping a Web Service")
uses as an example a web service that no longer exists :).
The GoogleSearch.wsdl was discontinued in August 2009.
See: http://googlecode.blogspot.com/2009/08/well-earned-retirement-for-soap-search.html

Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 06-Nov-2009 at 7:05pm

I couldn't find anything in the Dev Guide (or elsewhere) that
described exactly what the requirements are for the "web services"
that can be added to a domain model.  I would think DF
would be expecting certain types of methods that return
certain types of things.  No?

I'm _guessing_ that the Object Modeler is looking at my
particular web service and not finding what it wants,
so it can't generate a *.EDMX for it?

Thanks,
Alan

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 07-Nov-2009 at 5:25pm
When you choose "Add Web Service" from the Model menu, the Object Mapper is supposed to both generate a standard service reference, and generate an EDMX representing only the conceptual model.  The EDMX should be generated, even if no methods matched its requirements, and it should show messages for any errors found within the EDMX document.  So, if an EDMX isn't being generated, it's hard to say what's going on.  I will say that our support for web services within the Object Mapper is not currently particularly robust.
 
The requirement for mapped web methods / operations is that they take only primitive types as arguments and that they return a value (either a primitive or a "complex" type).  The return type is mapped as an Entity, and any other non-primitive types in the object graph are also mapped as entities.
 
We haven't yet updated our learning resource and documentation for the disappearance of the Google Search service, but thanks for reminding us.  We'll have both updated in a coming release.
 
If you need web service support please contact us directly (using the support request form on our web site - http://www.ideablade.com/CustomerSupportRequestForm.aspx) and let us know your requirements.
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 07-Nov-2009 at 9:51pm
Ok, thanks kimj.
Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 11-Nov-2009 at 11:16pm
Kimj,
 
I was getting the same error as Alan. Upon carefully re-reading the section on adding a web service, I realized that I must first select my server side domain model project before attempting to add the web service.
 
I've created a WCF service that has one method that returns a list of custom objects. I've tested the service using a console app and it returns the results that I expect.
 
When I attempt to add the service via the Object Mapper (ex: http://myserver/myservice/myservice.svc with a namespace of MyServiceReference), I can see that that it creates the MyServiceReference.edmx file, adds the service reference file and the VS2008 status bar reads:
 
Add service reference complete.
 
But the Object Mapper tool freezes up - and since it's a modal window, it causes the VS2008 to freeze up as well. I end up having to kill the process via task manager.
 
Any ideas as to why the process freezes?
 
Bob
 
Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 6:48am
Update
 
I was adding the Domain models via object mapper to an existing solution after I had created my projects for a prism/mvvm implementation.
 
I decided to create a new solution from scratch. Following the steps in the Hello DevForce & User guide, I was able to add a web service to my solution without the object mapper freezing up on me.
 
From now on, I'll be sure to create my domain models first before I start adding the prism components for an application.
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 8:25am
We haven't seen the OM freeze problem before, but thanks for the info.  We'll investigate further.
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 10:50am

Bob: Thanks for trying that out.

Inspired by Bob's success I tried again, but now I get a different error :).

Here are the steps I took:

I created a fresh DevForce Silverlight Application from the VS2008
template.  That creates a client-side SL project and a server-side
web project.  (It just displays "Hello DevForce!" at runtime in the
SL client).

Next I added an Entity Data Model for the NorthwindEF database to
the web project.  I include all the tables and all the views. 
A Model1.edmx file is successfully generated in the web project.

Next I add a "Silverlight-enabled WCF Service" to the web project
using the VS2008 template.  I add one method to it that returns
a List<String> collection.

I run the solution without the debugger, so that the DevForce
Object Mapper will be able to talk to the new web service.

I select the web project in the solution explorer.

Back in VS I run the DevForce Object Mapper from the Tools menu.
I pick Model / Add Web Service from the main menu.
The Object Mapper successfully discovers my web service.
I press "Ok" on the "Add Service Reference" dialog.  It crunches
a little, then the dialog closes and a message appears in the strip at
the bottom of VS saying "Add service reference complete".

But then the Object Mapper pops up a message box titled
"Add Web Service Error", with the message "Unable to add web service:
Index out of range.  Must be non-negative and less than the size
of the collection.  Parameter name: index".

Any idea what is going wrong?

Thanks,
Alan

Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 10:58am
Alan,
 
Here's an update on my environment.
 
In my case, my web service is in it's own seperate solution. I then have the web service running on an IIS server. So when the object mapper comes up, it "sees" the web service up & running.
 
In your case, you're adding the web service to your web project. I think the OM is getting "lost" when it's trying to access the service when it's part of your web project.
 
Hope this helps you out!
 
Bob
 
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 11:09am

Hi Bob,

Thanks for the feedback.

Before you responded I had gone a step further and
added a separate "WCF Web Service" project with
its own additional "Silverlight-enabled WCF Service"
to my existing solution.  But I get the same error from
the DevForce Object Mapper.

As you suggest, I'll try going even further and
move the web service out into a completely separate
solution (and maybe even hosted in IIS).

Thanks,
Alan

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 11:37am
Sorry for all the problems, guys.  Alan, the problem you're seeing might actually be due to the return data of the web method.  We do have a fix in current bits for problems encountered when returning an array from a web method.  I'd try changing the return type before moving the WCF service around, eg, something like this should work as a return type:
 
   [DataContract]
   public class AClass {
      [DataMember]
      public List<string> Strings { get; set; }
   }
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2009 at 5:00pm

kimj: Actually the simple method in my test web service
was already returning List<String>, the same as yours.

The problem seems to be that the DF Object Mapper does
not like the "Silverlight-enabled WCF Service".  I'm
not sure exactly why.  As long as I used a standard
"WCF Service", rather than the "Sliverlight-enabled
WCF Service", the DF Object Mapper had no errors adding it.

It didn't matter where I put the web service.  Even
hosting the SL-enabled one on IIS produced the same
"...Index out of range..." error message from the OM.
Hosting the standard "WCF Service" directly in the
Silverlight-hosting web app worked fine with the OM.

Alan
 
FWIW: Here is the exception and stack trace at the time of the error message
from the DF Object Mapper:
(I collected this with WinDbg+SOS from the devenv.exe VS process where
the OM is running as an Add-In):
 
Exception type: System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less than the size of the collection.
InnerException: <none>
 
StackTrace:
System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32)
System.Web.Services.Description.PortTypeCollection.get_Item(Int32)
IdeaBlade.VisualStudio.OM.WsSchemaProvider+ServiceInfoHelper.GetServiceOperations()
IdeaBlade.VisualStudio.OM.WsSchemaProvider.SelectSchemaItems()
IdeaBlade.VisualStudio.OM.SchemaProvider.AddNewEdmx(IdeaBlade.ModelGen.DataSourceType, EnvDTE.Project)
IdeaBlade.VisualStudio.OM.ModelGenerator.AddNewEdmx(IdeaBlade.ModelGen.DataSourceType, IdeaBlade.ModelGen.RootWrapper)
IdeaBlade.VisualStudio.OM.App.AppPresenter.AddWebService()
IdeaBlade.VisualStudio.OM.App.AppWindow.AddWebService_Executed(
                 System.Object, System.Windows.Input.ExecutedRoutedEventArgs)


Edited by Alan Cobb - 12-Nov-2009 at 7:14pm
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 13-Nov-2009 at 2:16pm

Since the DF-Object Mapper is able, within limits, to map a
"regular" WCF Service, I was able to move on to another
level of challenge.  (I'm still interested to know if there is
any work-around to get the OM to handle "Silverlight-enabled
WCF Services").

What I'm attempting to do is the following:

Background:
Brad Abrams has a blog article and Silverlight sample that
show how to use three, built-in web services exposed by
ASP.NET to manipulate the ASP.NET user/membership/profile system.
See: http://blogs.msdn.com/brada/archive/2008/05/03/accessing-the-asp-net-authentication-profile-and-role-service-in-silverlight.aspx

What I'm trying to do is to get the DF-Object Mapper to
map those three built-in ASP.NET web services:
    AuthenticationService.svc
    RoleService.svc
    ProfileService.svc

I am able to get the DF-Object Mapper to map all three
of them (and create service references for them) without
generating any error messages.  The problems show up
when I then try to build the solution.

Each of the web services gets a corresponding, generated
*.Designer.cs class.  Each has build errors related to the
generated types.

For example, the *.Designer.cs class generated for 
RoleService.svc has 5 compile errors:
"Cannot implicitly convert type 'string' to 'DomainModel.String'"

The *.Designer.cs generated for ProfileService.svc
has 168 compile errors.  Apparently the OM gets confused because
some of the web service methods use this .NET generic type:
Dictionary<string,object>.  In the generated ProfileService.edmx
and *.Designer.cs files that gets turned into the uncompilable
type named "DomainModel.Dictionary`2" (there is a strange
accent character before the "2").

-------------------------------------------------
So my conclusion is: If I wrote my own web services
and stuck to a limited set of simple types, I might be able to
get this to work.  But trying to map arbitrary web services
is not realistic today?  True?

Thanks,
Alan

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 13-Nov-2009 at 3:51pm
I'm afraid your conclusion is true.
 
I'm not sure what your requirements are, but you might have some alternatives.   
  • DevForce can use ASP.NET Membership directly for simple login/logout. 
  • You can pretty easily add access to the Membership API itself (and Roles and Profile) using DevForce support for POCO types.  We have a sample in the Learning Resources which uses both standard DevForce login support along with user registration implemented via POCO in the "100_Security\Samples\300SLV\CodeCS\ASPNET Membership with Registration" sub-folder.  If you use POCO, the provider can use the ASP.NET APIs directly, or the WCF services (or event the corresponding web services).
  • You can map the database tables in aspnetdb directly using standard EF and the Object Mapper.   I'm not sure if direct database access to these tables is recommended, but it's certainly possible.
 
Back to Top
Alan Cobb View Drop Down
Newbie
Newbie


Joined: 04-Nov-2009
Location: Northern CA
Posts: 16
Post Options Post Options   Quote Alan Cobb Quote  Post ReplyReply Direct Link To This Post Posted: 13-Nov-2009 at 4:39pm

Hi kimj,

>I'm afraid your conclusion is true.

Well, I realize the web-service mapping approach was a bit
of a long shot :).  I just wanted to make sure it wasn't
something I was doing wrong.

Re. your alternatives:

I had looked at the "300SLV / ASPNET Membership with Registration"
sample you mention, and yes, that would probably be Ok,
for at least part of what I want to do.

I had started investigating the third option you mention
(treat aspnetdb like any other database and manipulate
it through DF and EF).  I may give that a shot.  I'd
like to develop an "admin panel" where I can add and
remove users, change their settings, etc.

One question for you about the "300SLV" sample:
The way the code is written, it in-effect does some
security-sensitive branching based on client-side Silverlight
code.  That's Ok in some cases, but if the "Fetch" routine
they call brought back a security-sensitive list of users,
is there a way to add server-side code to only have that
"Fetch" succeed if the current user is for-sure a manager? 
Or is that kind of security something inherently built into
the server-side DF code?

Thanks,
Alan

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 14-Nov-2009 at 4:15pm
There's really no security shown in that particular sample.  The "ASP.NET Membership and Roles" and "ASP.NET Profile" samples in that same folder show a bit of a server-side security implementation using both declarative (the RequiresRoles and RequiresAuthentication attributes) and programmatic (using the Principal passed into a method) security implementations. 
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down