Error Consuming a WCF service on DiscountASP servers

Discussion in 'ASP.NET 2.0' started by jfasenmyer, Jan 8, 2008.

  1. I have multiple WCF services that I've published to my DiscountASP account. All services appear load correctly when directly referenced, https://www.domain.com/Services/AccountServices.svc. The services are currently unsecure aside from being referenced via https for simplicity. I've successfully added the service references to my ASP.NET website project. When I run the site project on my local development workstation, the application calls the services (hosted on the DiscountASP server) successfully without any issues. However when I publish the site to my DiscountASP account, I receive the following error...
    [​IMG]

    I've tried changing the bindings from wsHttpBindings to basicHttpBindings and receive the same error. I've also attempted publishing the site to my IIS 7 beta account on DiscountASP (my workstation is running Vista so I thought perhaps it was an IIS 6 / 7 issue) and still receive the same error. I've hashed and rehashed the Reference.svcmap files all afternoon but if the problem is a bad or invalid value in the svcmap file, why would itrun and connect frommy local machine correctly? I believe the problem may be related to the ASP.NET site resolving the service addresses which reside on the same account but have no method of testing or confirming any of this due to it being a hosted server.

    Below are the binding and endpoint values for one of the services (they are all the same format) thatVS 2008auto-generates when I add the service references...

     
  2. Let me simplify my request... does anyone have a working WCF serviceAND applicationutilizing the service on the DiscountASP servers? I would about give anything for a working HelloWorld example with functioning binding and endpoint settings.
     
  3. <STRIKE>I'll try and work on one tonight bro.
    <STRIKE>Haven't yet however.

    OhMyGosh...Didn't realize how deep WCF was. [​IMG]

    Found a bunch of samples here if they can help you run some tests:
    http://msdn2.microsoft.com/en-us/library/ms752239.aspx

    Salute,
    Mark


    Post Edited (wisemx) : 1/10/2008 12:59:41 AM GMT
     
  4. Hi Mark, I'll give these a shot and see if I can get them working on the DASP servers. If I manage to get one working, I'll be sure to post it to help anyone else out who may eventually encounter this. The binding &amp; endpoint settings can be simplified further than what is auto-generated by Studio but it still fails to work when I publish to the DASP servers. Thanks!

     
  5. I've broken this issue down to the simplest form of a HelloWorld client and service project (thanks again Mark for steering me in that direction). I've identified that the Reference.svcmap files auto-generated by VS 2008 will not work at allwhen published to theDiscountASP servers. Attempting to do so produces the error I've listed above. Due to my limited access, I don't know why this is. Running the ASP.NET consumer project from my local workstation (Vista with IIS 7) runs without issue. DiscountASP has provided a solution to the multiple header issue experienced when attempting to publish WCF services to their servers. However there appears to be no follow up to the requests at the bottom of the thread asking for a sample application which includes a project consuming the actual service itself.

    After spending yet another day troubleshooting this, I've found completely removing the App_WebReferences (where the svcmap file resides), copying all WCF service interfaces into your site project and then manually creating the channel, endpoint &amp; binding in code (see below) DOES work.

     
  6. I like the way you're handling this, very cool.
    One thing I ran into yesterday, inthe MSDN WCF swamp, was references to Hosts running in WCF Services compatibility mode.
    Apparently there are some settings you canset to change this compatibility behavior on shared hosts.
    I have no idea how DASP is running these services, and again I haven't done a lick of code with WCFyet.
    But that's something I'd suggest you look into...And yes, please do keep us posted.
    Salute,
    Mark

    P.S. I can't think of any WCF services to add to: http://sdknuts.net
    But I'm always up to a good community project to test this.
     
  7. Day 4, still no sign of support. I've started burning officefurniture for warmth as I huddle around my forum post waiting in hopes of an officialDASP response. Most of the nearby fast food chains won't serve me due to thestench after 4 days without a shower. My co-workers have started a petition to force the shower issue. My faith thatanyone is activelyconsuming WCF services on the DASP servers is faltering. In the meantime, I'm uploading my custom HelloDASP WCF and client folders in further hopes of displaying that even a simple HelloWorld WCF client does not work for some unknown reason on the DASP servers...


    DASPService - A simple WCF service using httpBasicBinding with a single method, SayHello. Method returns "Hello DASP!".


    DASPClient_Custom - Client ASP.NET site that manually createsthe channel, binding &amp; endpoints to call the service. This is the workaround I've found, however you need to include the service interface class and all custom classes that the interface classes use (return values &amp; parameters). While this works for a simple HelloWorld example, it's not so great with a 'real world' project that uses a good number of custom classes as return values and/or parmeters.


    DASPClient_AutoGen - A copy of the DASPClient_Custom site but with services added via the VS 2008 IDE (Add Service Reference). This creates the App_WebReferences folder and the svcmap config file (along with the wsdl, schema &amp; disco) which causes the project, when published to the DASP servers, to crash. However, it runs perfectly fine on my local workstation.


    Please note that you will need to update the http://www.domain.com/DASPService/Service.svcreference with your own domain name and pathing if you've placed it elsewhere. Also all 3 will need to be configured as applicationswith the Web Application Tool.




    Post Edited (jtf) : 1/11/2008 6:50:36 PM GMT
     

    Attached Files:

  8. <STRIKE>You're cracking me up bro...I've D/L'd the file and will look into it soon. [​IMG]

    I'm stuck.

    Placed your files on the server, made the necessary changes, created an application for /services/
    Have duplicated the services files...
    But still the service fails and I can't figure out why so far.
    http://sdknuts.net/service/DASPClient_Custom/
    http://sdknuts.net/service/DASPClient_AutoGen/

    One thing that bothers me about the code currently would be the multiple web.config files.
    Another is the services aren't in a better location, the \App_Code\ folder.
    But I duplicated it and still got the same result.

    That's where I'm stuck, but the compilation output does show an access denied behavior...
    However that could be because of the IService resource error.

    Yeah, I'm stuck...But at least wanted to give you this much.
    Salute,
    Mark


    Post Edited (wisemx) : 1/11/2008 4:26:44 PM GMT
     
  9. The IService.cs class should've been included in both projects in the App_Code folder. You can find this class in the DASPService if you want to try copying it over. I'll update the zip in a few. Sorry about that! I've spent a lot of time messing with these so I likely deleted it prior to creating the zip. Your help is tremendously appreciated.

     
  10. No prob, I had to remove some of the references quick, they were affecting my site.
    (Dropped your CS code in my VB APPcode, duh.)
     
  11. I've updated the zip to include the IService.cs file.
     
  12. I made some physical changes and did make some progress.
    At least got it to the point where it would end with a parse error on the Host.
    I attached my changes, take a look and see if you can do any better with this one.
    Would take me at least a week or two to get used to these new services and the xml formatting.
    Salute,
    Mark
     

    Attached Files:

  13. Were you receiving the same parser error as the one I originally posted? I'm almost convinced at this point that the DASP IIS is not handling svcmap files correctly. Unfortunately, I have no way of further troubleshooting this due to my limited access and their reply buttons appear to be broken at the moment.

     
  14. No I didn't get to the parser until I reconstructed that.
    I'm pretty sure with a couple of weeks studying it I could find out what the problem is.
    One thing I meant to do that last time as update the web.config for .NEt 3.5, but didn't.
     
  15. Have you tried the sample WCF service here. The original post has a zip of a very simple service.
    http://community.discountasp.net/default.aspx?f=24&amp;m=16709


    In the Services.cs, change the code to match your serivice URL in the CreateServiceHost override method.
    In the Web.config, change the service binding from wsHttpBinding to basicHttpBinding.

    Create a web reference in your client application like you would normally do an ASMX web service, referencing http://www.domain.com/WCFService/Service.svcor whatever your URL instead.


    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  16. Hi Aristotle,
    Thank youfor the response! I'velooked atthe sample WCF service (reference it above) and even created the channel factory as you instructed. It works great and resolves the multiple host header issue which I initially encountered. I've also tested adding the WCF service as an ASMX web service. This also works but I don't understand why can't I add the WCF service as a WCF service and take advantage of the wsHttpBinding features. Does DASPhave any plans of supporting any bindings other than the basicHttpBinding?


    I understand this is all still very new but with VS 2008 hitting retail soon, I doubt I'm going to be theonlydeveloper who wants take advantage of some of the new features offered with .NET 3.5. If DASP is only supporting the basicHttpBinding for now, I can live with that but I just wanted to verify that the parser error when adding a WCF service as a WCF service was not just on my end. Thanks again!


    Post Edited (jtf) : 1/14/2008 10:17:44 PM GMT
     
  17. I'll have to check my samples again for implementing wsHttpBinding. It's been a while since I looked atWCF. I do remember that with it's default settings of using Windows authentication, I could getit to work ifthe service and client apps wereon the same site. Working across the internet could be trickier.








    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  18.  
  19. Update: Tried switching authentication from Forms to Windows as you suggested and Istill getting the parser error. We're not even talking wsHttpBindings here, just basicHttpBindings with a simple "Add Service Reference" reference map file. I'm a sad panda. [​IMG]
     
  20. So now I discover how bleeding edge I am! I figured I was an hour away from deploying a production WCF service and I run into the svcmap parse error thingy. It took me a few hours but I have a workaround ready for production. :) right....

    Here'smy solution :

    1. Deployed my IIS6-hosted WCF service and fixed-up all the standard stuff (needed to add a .svc file to the vroot e.g.). BTW, I developed the WCF service using the a WCF lib project type and the trusty VS 2008 built-in host. It's the only way to fly.

    2. Deployed my ASP.NET/IIS6 web application which is the client to above WCF service. Fixed up the URL from the development URI to the above production endpoint from step 1.

    3. Failed the &amp;*^^&amp;^%$* svcmap parse.

    4. Cursed MS to eternal fire.

    5. Opened up VS 2008 and created a simple C# console app and added a service reference to the WCF production endpoint from step 1.

    6. Used VS 2008 to browse to the service definition and SCHWING!!!! I am now looking at the tool generated C# proxy for the production endpoint!!!

    7. Had to fix up the generated code's namespace from step 6 to match the types in my client webapplication using VS search and replace. You will hit about 3-4 qualified type names in the generated code that you'll need to change.

    8. Deleted the entire svcmap folder on the production vroot for web application (step2.).

    9. Dropped the generated/fixed-up client code from step 6 into the app_code folder of the IIS6 web app client that was failing the svcmap parse.

    10. Ran the web app and it worked!!!! No change to any code in the original client or server code base.

    11. Now onto to securingthe whole deal usingx.509 certs. ala Juval's Internet security scenario. I'm sure that'll be a party.
     
  21. Awesome Ken...Next Espresso is on me. [​IMG]
     
  22. Can you post a working sample of the client &amp; service? I tried creating a console app that consumed the WCF service and replacing the files in the App_Webreferences folder (there was no svcmap directory) but it made no difference. I'm also confused what exactly in step 9 was copied into the app_code folder. I'm happy to see that someone has managed to get the services working, I'm just confused as to what exactlyresolved the problem. I'm still stuck on steps 3 and 4 of your solution. Thank you.

     
  23. The fundemental problem created by this error is that there is no proxy on the deployment target if .svcmap cannot be parsed. If you can generate a proxy (C# in my case) and drop it into the app_code folder on the deployment machine, then ASP.NET will compile the type and bind to it at runtime. I looked at the venerable svcutil command line tool for WCF proxy generation and decided that it was not the rabbit hole I cared to drop intoat this time. It's pdaunting to say the least and good candidate for future study. If you're good with it, then that would be the best choice.

    Instead, I reasoned that the VS 2008 console project type, since it cannot benefit from ASP.NET on-demand compilation,must have aVS 2008 generated proxy (maybe by invoking svcutil)that I could copy and use on the server. It turns out that this is actually the case. Again, I added a service ref. in my VS 2008 console application to the WCF service, and found the type name that was generated. I right-clicked on the type name in the source code editor and selected "Go to definition". This action took me to the VS generated source code for the WCF service proxy. From there, I made sure to edit the proxy to exactly match the fully namespace-qualified types I used in the failing project and dropped the result into the app_code folder. ASP.NET compilied the result and bound to it at resolved the types at runtime and all was working. Make sure to delete the svcmap folder in it's entirety on the server to rid yourself of the parse error.

    kg
     

Share This Page