|
-
Feb 19th, 2009, 10:39 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Feb 19th, 2009, 10:42 AM
#2
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.
-
Feb 19th, 2009, 10:45 AM
#3
Thread Starter
Hyperactive Member
Re: WCF Service problems
Do you want all of it, or any part in particualr?
-
Feb 19th, 2009, 11:09 AM
#4
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.
-
Feb 19th, 2009, 11:17 AM
#5
Thread Starter
Hyperactive Member
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>
-
Feb 19th, 2009, 11:47 AM
#6
Re: WCF Service problems
OK, so far everything looks good, and you're right, that should work. How are you invoking the web service?
-
Feb 19th, 2009, 12:18 PM
#7
Thread Starter
Hyperactive Member
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.
-
Feb 19th, 2009, 01:16 PM
#8
Thread Starter
Hyperactive Member
Re: WCF Service problems
Found this
Seems I was right about it being a Windows 7 issue.
-
Feb 19th, 2009, 06:39 PM
#9
Re: WCF Service problems
Odd, if that worked for you.
What about basicHttpBinding then? That should work regardless.
-
Feb 20th, 2009, 06:23 AM
#10
Thread Starter
Hyperactive Member
Re: WCF Service problems
It works, but I decided to do basicHttpBinding for now, cause that works as well.
-
Feb 20th, 2009, 08:11 AM
#11
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.
-
Feb 20th, 2009, 08:18 AM
#12
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|