我正在用visual basic構建一個簡單的web服務。這個Web服務應該輸入一個JSON並返回一個值。 此Web服務的方法是POST。如何在Visual Basic中構建Web服務休息?
這是代碼:
<WebMethod()>
Public Function MB_InsertBeetrader(ByVal inputData As AMAServerInputData) As AMAServerOutputData
Dim returnData As New AMAServerOutputData()
Try
Catch ex As Exception
returnData.Messages.AddExceptionMessage(ex)
End Try
Return returnData
End Function
End Class
Public Class AMAServerInputData
Inherits Base_ServerInputData
Public Username As String
Public Password As String
End Class
如果我試圖從我的郵遞員客戶端調用這個方法我有一個錯誤。 這是我的電話:
{ "Username": 656,
"Password": "128"
}
這是錯誤:
{ "Message": "Chiamata a servizio Web non valida. Valore mancante per il parametro 'inputData'.", "StackTrace": " in System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary
2 parameters)\r\n in System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary
2 parameters)\r\n in System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n in System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)", "
感謝您的回答,您能舉個例子嗎? – bircastri
@bircastri一個什麼樣的例子? –