View Full Version : WCF Client & Service Sample
jfasenmyer
01-21-2008, 10:46 AM
Has this forum been here the whole time? If so, I don't know how in the world I missed it. Either way, since you guyshave'officially' set up a support forum can we PLEASE PLEASE PLEASE have a working WCF sample (client AND service samples)? Please? I'm referring to my original thread posted here (http://community.discountasp.net/default.aspx?f=24&m=21726). Please?
bruce
01-22-2008, 12:23 PM
I thought Aristotle gave you a sample code. Didn't that work?
Bruce
DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)
wisemx
01-22-2008, 12:25 PM
No it was added recently.
Did you find anything on this yet:
Hosting WCF Services in ASP.NET Compatibility Mode
http://msdn2.microsoft.com/en-us/library/aa702682.aspx
I've been spending my time with Silverlight since we last dialogue'd. http://community.discountasp.net/emoticons/wink.gif
jfasenmyer
01-23-2008, 07:17 AM
I was not supplied with a code sample other than what is already stickied. Unfortunately the stickied post does not contain a sample that consumes the service which is where my problem lies. He did mention that he gotten a client to work butcouldn't recall much other than the authentication in the web.config was set to Windows. I've triedthis with my HelloDASP sample that I uploaded to the thread it still received the same parser error.
[quote]To reproduce the error create two VS 2008 projects, an ASP.NET web site that will serve as the client and a WCF Service Application. Add a simple method & interface to the service that returns a string and create a custom factory per Aristotle's post (http://community.discountasp.net/showthread.php?p=30492). Publish the service to the DASP server.
[quote]Add the service to your ASP.NET client project via the VS 2008 "Add Service Reference". Instantiate the service, call the 'Hello' method and Response.Write the result. The project should run fine locally but throws a parser error when uploaded to the DASP server.
[quote]I know you can use the basicHttpBinding and call the service as a regular ASMX service but this isn't a solution. Doing so restricts you to only the basicHttpBinding and does not allow you to use the 3.0 /3.5WCF as intended. The problem isn't the binding, it's the svcmap file that VS 2008 autogenerates. I don't know why butthe 2008'cookie cutter'svcmap file does not play nice on the DASP IIS.
[quote]
bruce [DASP] said...
I thought Aristotle gave you a sample code. Didn't that work?
jfasenmyer
01-23-2008, 07:31 AM
I did check intosome ASP.NET compability articles. Changing the setting in the web.config resulted in the same error. I did just notice in the article you linked thatI have theaspNetCompatibilityEnabledset to true anddo not have any [AspNetCompatibilityRequirementsMode]attribute defined in the code. It's possible this setting could be somehowcausing the problem but you'd think the error would further imply it if that were the case. Either way I'll test this out & let you know the outcome. Again, your help is greatly appreciated.
wisemx said...
No it was added recently.
Did you find anything on this yet:
Hosting WCF Services in ASP.NET Compatibility Mode
http://msdn2.microsoft.com/en-us/library/aa702682.aspx
I've been spending my time with Silverlight since we last dialogue'd. http://community.discountasp.net/emoticons/wink.gif
NetRebel
03-08-2008, 05:20 AM
Having the same problem. Frustrating.
http://community.discountasp.net/emoticons/idea.gif can someone be a hero and post a simple "Hello World" sample of a WCF client and server in VB .Net 2008 using IIS7 hostingand the wsbinding?
Maybe also some simple notes of setting up in IIS7 http://community.discountasp.net/emoticons/yeah.gif
wisemx
03-08-2008, 05:34 AM
I'd help with some code tests for this but recently switched to Vista and am still getting my Dev tools configured.
Something you may want to check out however, for good resources, is...
http://netfx3.com/content/WCFHome.aspx
Salute,
Mark
Note: The transition to Vista hasn't been bad at all.
Only problem I've hadso far is my current version of Camtasia Studio.
Fortunately the upgrade toC.S. v5 will take care of that, unfortunately the upgrade is $150. http://community.discountasp.net/emoticons/freaked.gif
NetRebel
03-08-2008, 05:49 AM
Thanks Mark
I am going to post whatever I find back here also.
bruce
03-13-2008, 09:09 AM
I got wcf to work on iis7. See http://www.iis7hosting.com/asp.net/wcf/service.svc
Let me know if you need the code, i'll send it to you.
Bruce
DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)
bobfamiliar
03-24-2008, 06:57 AM
I found some sample code on how to implement a WCF service that fixes this issue:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Details are on Rob Zelts blog:
http://www.robzelt.com/blog/CommentView,guid,b53a709e-cd21-460f-a33b-c7a8e02e8bd6.aspx#commentstart
You need to implement a custom service factory, custom service host and modify the SVC file to reference the factory.
class CustomHostFactory : ServiceHostFactory {
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) {
CustomHost customServiceHost = new CustomHost(serviceType, baseAddresses[1]);
return customServiceHost;
}
}
class CustomHost : ServiceHost {
public CustomHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { }
protected override void ApplyConfiguration() {
base.ApplyConfiguration();
}
}
<%@ ServiceHost Language="C#" Debug="true" Service="HelloWorldService.Service1" Factory="HelloWorldService.CustomHostFactory" CodeBehind="Service1.svc.cs" %>
Note: In development I had to change this line of code from
CustomHost customServiceHost = new CustomHost(serviceType, baseAddresses[1]);
to
CustomHost customServiceHost = new CustomHost(serviceType, baseAddresses[0]);
To get it to work locally. I then change that line backbefore publishing to my site.
I've attached the complete VS2008 project solution.
-bob familiar
vBulletin® ©Jelsoft Enterprises Ltd.