168 messaggi dal 17 febbraio 2009
Ciao, sto sviluppando un piccolo servizio wcf da interrogare con un client iPhone iOS.

questa è il metodo che aggiunge un nuovo utente alla app:
Public Sub putUserAccount(username As String, newUser As UserAccount) Implements ILostAndFoundService.putUserAccount
        userAccountService = New UserAccountService
        Try
            userAccountService.CreateUserAccount(newUser)
        Catch ex As Exception
                Select ex.GetType
                Case GetType(UserAccountAlredyExistException)
                    Throw New WebFaultException(Of String)("User already exists", Net.HttpStatusCode.InternalServerError)

            End Select
        End Try

    End Sub


e questa è la sua dichiarazione:
<OperationContract()>
    <WebInvoke(Method:="POST", UriTemplate:="users/{username}", ResponseFormat:=WebMessageFormat.Json)>
    Sub putUserAccount(ByVal username As String, ByVal newUser As UserAccount)


Il servizio accetta correttamente le richieste in formato json, ma se si verifica l'eccezione, questa viene inoltrata in XML (testato con Fiddler)

l'endpointBehaviors nel mio webconfig è il seguente:
 <endpointBehaviors>
                <behavior name="RestConfiguration">
                    <webHttp helpEnabled="True" defaultOutgoingResponseFormat="Json" defaultBodyStyle="Bare" faultExceptionEnabled="True" />
                </behavior>
            </endpointBehaviors>


come faccio a restituire il dettaglio dell'eccezione in json e non in xml??
168 messaggi dal 17 febbraio 2009
Errore di sintassi nel web.config!
Risolto il problema!

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.
Community
Ultimi messaggi
UTENTI ONLINE
In primo piano

I più letti di oggi

Media
In evidenza
MISC