Whenever I try to throw a new FaultException(Of MyFault)(myFaultInstance) from my service implementation, I receive the following exception: 'Unspecified ServiceModel Fault'. I have the FaultContract specified in the service contract on both the service and client. I'm getting this exception on the service side.
Thanks.
Phil

Unspecified ServiceModel Fault
RicardoA
on the client side,we are able to detect right fault ,but for some reason fault reason and message is not serialized properly.
-Thank you
Madhu
PFS
My problem was as defined in the link http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=416668&SiteID=1
Also the solution is defined there. It is Visual Studio Configuration issue.
- Pankaj.
Michael Braaldey
Now I am getting this error. I have win ui for both server and client side.
I did not get clear from the above thread what was the solution.
Thanks,
- Pankaj.
Brasiliansbr
If possible,can you please share your service code and config and client code and config
-Thank you
Madhu
pc0416
Detail object has your fault object information,so you can access Detail object to access all your fault contract obeject data
Example:
Try
Catch ex As FaultException(Of RequestEmployeesFault)
Console.WriteLine(ex.Detail.DetailedReasonProperty.ToString())
End try
'I modified your code ltl bit (I am not vb expert,so just to simplify)
SERVICE CODE:
============
Imports System
Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports System.IO
Namespace TestSamples
<DataContract()> _
Public Class RequestEmployeesFault
<DataMember()> _
Public DetailedReason As String
End Class
<ServiceContract()> _
Public Interface IEmployeeService
<OperationContract()> _
<FaultContract(GetType(RequestEmployeesFault))> _
<FaultContract(GetType(FileNotFoundException))> _
Function RequestEmployees() As String
<OperationContract()> _
Function Helloworld() As String
End Interface
'Service Implementation
<ServiceBehavior()> _
Public Class Testsvc
Implements IEmployeeService
Public Function RequestEmployees() As String Implements IEmployeeService.RequestEmployees
Dim fault As New RequestEmployeesFault
fault.DetailedReason = "aha,I got exception,watch me on client side"
Throw New FaultException(Of RequestEmployeesFault)(fault)
Return "Hello"
End Function
Public Shared Sub Main()
Dim obj As New ServiceHost(GetType(Testsvc), New Uri("http://localhost:8000/testsv/hello"))
obj.Open()
Console.WriteLine("Service is ready to take calls")
Console.ReadKey()
End Sub
Public Function Helloworld() As String Implements IEmployeeService.Helloworld
Return "Hello world"
End Function
End Class
End Namespace
SERVICE CONFIG:
===============
< xml version="1.0" encoding="utf-8" >
<configuration>
<system.serviceModel>
<services>
<service name="VBWCFSVC.TestSamples.Testsvc">
<endpoint address="" binding="basicHttpBinding"
contract="VBWCFSVC.TestSamples.IEmployeeService" />
</service>
</services>
</system.serviceModel>
</configuration>
CLIENT CODE:
===========
Imports System
Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports VBCLIENT.localhost
Imports System.IO
Module Module1
Sub Main()
Try
Dim obj As New localhost.EmployeeServiceProxy
Console.WriteLine(obj.RequestEmployees())
Catch ex As FaultException(Of FileNotFoundException)
Console.WriteLine("we got right exception handler,Fault is :" & ex.Message.ToString())
MsgBox(ex.Detail.Message.ToString())
Catch ex As FaultException(Of RequestEmployeesFault)
Console.WriteLine("we got right exception handler,Fault is :" & ex.Message.ToString())
Console.WriteLine(ex.Detail.DetailedReasonProperty.ToString())
Catch ex As Exception
Console.WriteLine("we got wrong exception handler,fault is: " & ex.Message.ToString())
End Try
Console.ReadKey()
End Sub
End Module
CLIENT CONFIG:
=============
< xml version="1.0" encoding="utf-8" >
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IEmployeeService" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/testsv/hello" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IEmployeeService" contract="VBCLIENT.localhost.IEmployeeService"
name="BasicHttpBinding_IEmployeeService" />
</client>
</system.serviceModel>
</configuration>
armagane
Service Contract:
<ServiceContract()> _
Public Interface IEmployeeService
<OperationContract(Action:="urn:RequestEmployees")> _
<FaultContract(GetType(RequestEmployeesFault))> _
Function RequestEmployees( _
ByVal requestMessage As RequestEmployeesRequestMessage) As RequestEmployeesResponseMessage
End Interface
Service Implementation
Private Function RequestEmployees( _
ByVal requestMessage As RequestEmployeesRequestMessage) As RequestEmployeesResponseMessage _
Implements Contracts.IEmployeeService.RequestEmployees
Try
Dim responseMessage As RequestEmployeesResponseMessage = New RequestEmployeesResponseMessage()
Dim args As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
args.Add("Request", requestMessage)
args.Add("Response", responseMessage)
' Execute Business Process with Request and Response
' Testing Fault, so Throw Exception Throw New Exception()
Return responseMessage
Catch e As Exception
Dim fault As New RequestEmployeesFault
fault.DetailedReason = "Service Unavailale."
Throw New FaultException(Of RequestEmployeesFault)(fault)
End Try
End Function
Fault Contract
<Serializable()> _
<DataContract([Namespace]:=Constants.DEFAULT_NAMESPACE)> _
Public Class RequestEmployeesFault
Private _Reason As String
<DataMember()> _
Public Property DetailedReason() As String
Get
Return _Reason
End Get
Set(ByVal value As String)
_Reason = value
End Set
End Property
End Class
Service Configuration
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
maxMessagesToLog="1000" maxSizeOfMessageToLog="2147483647">
<filters>
<clear />
</filters>
</messageLogging>
</diagnostics>
<services>
<service type="Employee.Implementation.EmployeeService"
behaviorConfiguration="EmployeeServiceBehavior"
>
<endpoint address="EmployeeService"
binding="wsHttpBinding"
bindingConfiguration="ReliableHttp"
contract="Employee.Contracts.IEmployeeService">
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="ReliableHttp">
<reliableSession enabled="true" ordered="true"/>
<security mode = "None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<behavior
name="EmployeeServiceBehavior"
returnUnknownExceptionsAsFaults="True" >
</behavior>
</behaviors>
</system.serviceModel>
I had tried this with and without the behaviors section in the service config. When running this example in VS, I get an unhandled exception when I tried to throw the FaultException. In VS I view detail of this exception and the message is "Unspecified ServiceModel Fault".