Results 1 to 12 of 12

Thread: [RESOLVED] WCF Service problems

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Resolved [RESOLVED] WCF Service problems

    I can't seem to get even the simplest WCF Service working. May be something with my setup, I'm hoping you guys know. My service opens without errors in IE when I press Ctrl+F5. If I copy the URL, start wcftestclient.exe and paste the URL, I get a nice interface with the operations defined in my ServiceContract. So far so good. When I try to use one of the operations though, I get the following error message:
    "The remote server returned an unexpected response: (400) Bad Request."

    I'm running the Windows 7 Beta, could that be the problem? Or is this something completely different. I'm lost here, so any help is appreciated.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: WCF Service problems

    We'll need to see code, WCF problems cannot be easily solved without looking at code and the relevant web.config sections.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: WCF Service problems

    Do you want all of it, or any part in particualr?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: WCF Service problems

    From the config file, all the <endpoint> nodes, the <behavior> nodes and related configuration nodes.

    From the code... just the method you're trying to invoke and the code you're using to try and invoke it(client). I think this may be more of a reference problem than a code problem though.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: WCF Service problems

    IChatService.vb
    Code:
    <ServiceContract()> _
    Public Interface IChatService
    
        <OperationContract()> _
        Sub SubmitMessage(ByVal value As ChatMessage)
    
        <OperationContract()> _
        Function GetMessages() As List(Of ChatMessage)
    
    End Interface
    
    <DataContract()> _
    Public Class ChatMessage
    
        <DataMember()> _
        Public Sender As String
    
        <DataMember()> _
        Public MessageText As String
    
    End Class
    ChatService.svc.vb
    Code:
    Public Class ChatService
        Implements IChatService
    
        Private _Messages As List(Of ChatMessage)
    
        Public Function GetMessages() As System.Collections.Generic.List(Of ChatMessage) Implements IChatService.GetMessages
            Return _Messages
        End Function
    
        Public Sub SubmitMessage(ByVal value As ChatMessage) Implements IChatService.SubmitMessage
            _Messages.Add(value)
        End Sub
    End Class
    ChatService.svc
    Code:
    <%@ ServiceHost Language="VB" Debug="true" Service="ChatServiceLibrary.ChatService" CodeBehind="ChatServiceLibrary.ChatService.svc.vb" %>
    From Web.config
    Code:
      <system.serviceModel>
        <bindings />
        <client>
          <endpoint binding="wsHttpBinding" bindingConfiguration="" contract="ChatServiceLibrary.IChatService"
            name="WS" />
        </client>
        <services>
          <service behaviorConfiguration="ChatServiceLibrary.ChatServiceBehavior"
            name="ChatServiceLibrary.ChatService">
            <endpoint address="mex" binding="mexHttpBinding" name="MEX" contract="IMetadataExchange" />
            <endpoint binding="wsHttpBinding" bindingConfiguration="" name="WS" contract="ChatServiceLibrary.IChatService" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ChatServiceLibrary.ChatServiceBehavior">
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: WCF Service problems

    OK, so far everything looks good, and you're right, that should work. How are you invoking the web service?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: WCF Service problems

    In Visual Web Developer I press Ctrl+F5 to run the service, this will display the address of the service on a web page. I then run wcftestclient.exe and add the service using the address from the web page.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: WCF Service problems

    Found this
    Seems I was right about it being a Windows 7 issue.

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: WCF Service problems

    Odd, if that worked for you.

    What about basicHttpBinding then? That should work regardless.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: WCF Service problems

    It works, but I decided to do basicHttpBinding for now, cause that works as well.

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] WCF Service problems

    Alright, sorry if my answers seem vague or unsatisfactory to you, WCF questions are usually quite hard to troubleshoot because of its inherent nature - a lot of code needs to be shown and the web.config is extremely important because they've abstracted it so that the XML does all the heavy lifting for you. You sometimes end up in these strange scenarios which are caused by things that you had never imagined before.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: [RESOLVED] WCF Service problems

    I'm very happy with your answers. I mostly post here to get directions anyway. Don't want someone to solve my problems for me (well, sometimes I do!), just need a nudge in the right direction. It's only a hobby for me, nothing crucially important or on a deadline or anything.
    You helped me a lot by asking for that section of web.config. It made me take a better look at that file, and I now understand what the svcconfigeditor tool does. So thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width