servicestack을 사용하여 웹 서비스에 파일을 게시하는 방법을 파악하려고합니다. 내 클라이언트에 다음 코드가 있습니다.Servicestack PostFileWithRequest 사용 방법
Dim client As JsonServiceClient = New JsonServiceClient(api)
Dim rootpath As String = Server.MapPath(("~/" + "temp"))
Dim filename As String = (Guid.NewGuid.ToString.Substring(0, 7) + FileUpload1.FileName)
rootpath = (rootpath + ("/" + filename))
FileUpload1.SaveAs(rootpath)
Dim fileToUpload = New FileInfo(rootpath)
Dim document As AddIDVerification = New AddIDVerification
document.CountryOfIssue = ddlCountry.SelectedValue
document.ExpiryDate = DocumentExipiry.SelectedDate
document.VerificationMethod = ddlVerificationMethod.SelectedValue
Dim responseD As MTM.DTO.AddIDVerificationResponse = client.PostFileWithRequest(Of DTO.AddIDVerificationResponse)("http://localhost:50044/images/", fileToUpload, document)
아무리해도 "방법이 허용되지 않습니다."라는 오류 메시지가 나타납니다. 당신은 내가 아직 서버에있는 파일을 처리하기 위해 시도하지 않은 볼 수 있듯이 순간에 서버 코드는이
Public Class AddIDVerificationService
Implements IService(Of DTO.AddIDVerification)
Public Function Execute(orequest As DTO.AddIDVerification) As Object Implements ServiceStack.ServiceHost.IService(Of DTO.AddIDVerification).Execute
Return New DTO.AddIDVerificationResponse With {.Result = "success"}
End Function
End Class
같이 기록됩니다. 난 그냥 실제로 서버에 파일을 보낼 수 있는지 확인하기 위해 클라이언트를 테스트하고 싶습니다. 내가 뭘 잘못하고 있는거야?
나는 새로운 스타일의 API로 이동 계획입니까하지만 지금 나는이 문제에 대한 빠른 수정이 필요합니다
파일을 업로드의 예
는 RestFiles integration tests에 포함되어 있습니다. 예를 들어 PostFileWithRequest를 사용하는 방법이나 "지금 허용 된 메서드"가 표시되는 방법을 보여주는 예제가 없습니다. 이전 스타일 API를 사용하여 코드에서 잘못하고있는 것이 있습니까? –405의 Method Not Allowed가 나타나는 경우 [WebDav 제거] (http://stackoverflow.com/a/10283694/85785) – mythz
이 필요합니다.이 기능은 저에게 적합하지 않습니다. 지시에 따라 을 추가했지만 여전히 허용되지 않는 메서드를 가져옵니다. 누구나 더 이상 아이디어가 없습니까? –