2016-12-21 2 views
1

VB.Net에서 WCF 안정적인 API를 만들고 지금까지 한 매개 변수로 데이터를 저장하고 데이터를 저장하는 MSSQL 데이터베이스가 현재 작동하고 있습니다. 현재 사용자 로그인을 인증하기 위해 여러 매개 변수 (전자 메일 및 암호)를 사용하여 서비스 계약을 작성하려고합니다. 이것은 다음과 같은 오류를 던지고 유지하고 난 그냥이 해결하는 방법을 알아낼 수 없습니다 :WCF 다중 매개 변수가있는 안정된 API

Error: Cannot obtain Metadata from localhost:12345/SMPCService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: localhost:12345/SMPCService.svc Metadata contains a reference that cannot be resolved: localhost:12345/SMPCService.svc'. The requested service, 'localhost:12345/SMPCService.svc' could not be activated. See the server's diagnostic trace logs for more information.HTTP GET Error URI: localhost:12345/SMPCService.svc There was an error downloading '/localhost:12345/SMPCService.svc'. The request failed with the error message:--

이 내 서비스 계약입니다 :

<OperationContract()> 
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="ValidateLogin/{e}/{p}")> 
Function ValidateLogin(ByVal sEmailAddress As String, ByVal sPassword As String) As List(Of CheckLogin) 

을 그리고 이것은 호출되는 ValidateLogin 기능입니다 :

,692,283 : 마지막으로

Public Function ValidateLogin(ByVal sEmailAddress As String, ByVal sPassword As String) As List(Of CheckLogin) Implements ISMPCService.ValidateLogin 
    Dim result As List(Of CheckLogin) = New List(Of CheckLogin) 
    Dim uAction = New CheckLogin 
    Dim pwd As String = "" 
    Try 
     ' Dimension Local Variables 
     Dim uRecSnap As ADODB.Recordset 

     ' Check For Open Connection 
     If uDBase Is Nothing Then 
      OpenConnection() 
      bConnection = True 
     End If 

     ' Run Stored Procedure - Load Timesheet Record 
     uCommand = New ADODB.Command 
     With uCommand 
      .ActiveConnection = uDBase 
      .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc 
      .CommandTimeout = 0 
      .Parameters.Append(.CreateParameter("@EmailAddress", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30, sEmailAddress)) 
      .CommandText = "API_WebUser_ValidateLogin" 
      uRecSnap = .Execute 
     End With 

     ' Populate List 
     Do Until uRecSnap.EOF 
      pwd = If(IsDBNull(uRecSnap("UserPassword").Value), "", uRecSnap("UserPassword").Value) 
      uRecSnap.MoveNext() 
     Loop 
     uRecSnap = Nothing 

     If pwd <> "" Then 
      If pwd.Substring(0, 4) = "$2y$" Then 
       Mid(pwd, 3, 1) = "a" 
      End If 

      If BCrypt.Net.BCrypt.Verify(SHA512Hash(sPassword), pwd) Then 
       uAction.WasSuccessful = "OK" 
       uAction.StatusDescription = "User credentials match" 
      Else 
       uAction.WasSuccessful = "FAIL" 
       uAction.StatusDescription = "Failed to authorize user" 
      End If 

     Else 
      uAction.WasSuccessful = "FAIL" 
      uAction.StatusDescription = "Failed to authorize user" 
     End If 

     result.Add(uAction) 
    Catch ex As Exception 
     ' Catch Error 
     If Err.Number <> 0 Then 
      Console.WriteLine(ex.Message) 
     End If 

    Finally 
     ' CleanUp 

     ' Close Database Connection 
     If bConnection Then CloseConnection() 

    End Try 

    Return result 
End Function 

이 내의 Web.config입니다 (210)

나는이 문제에 대한 힌트를 찾기 위해 많은 게시물로 보았다하지만 난 아무데도하지 않았다. 내가 잘못 어디로 갔는지

Why do I get this WCF error when 'GET'ing?

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.`

How to send email address as parameter in wcf method

http://jeffbarnes.net/blog/post/2006/10/16/metadata-exchange-endpoint.aspx

+0

'변경해보십시오 <엔드 포인트 주소 = "../ SMPCService.svc"'에'<엔드 포인트 주소 = "SMPCService.svc"'. 또한 RESFUL WCF 서비스는 메타 데이터를 게시하지 않아도됩니다 (host : post/some.svc? wsdl을 사용하여 wsdl을 볼 수는 있지만) –

+0

@AmitKumarGhosh 끝 점이 변경되었지만 여전히 똑같은 오류 메시지가 나타납니다. 다른 두 서비스 계약이 어떻게 작동하는지는 이상하게 들리지만 두 매개 변수가있는이 서비스 계약은 문제를 일으 킵니다. – Nayon

+0

'WebMessageBodyStyle.Wrapped'는 요청이 래핑 될 것으로 기대하기 때문에 제거하려고 시도하지만 실제로는하지 않습니다. –

답변

0

다른 접근을 시도 후, 나는 마침내 해결 한 :

게시물 나는 살펴 보았다.

함수의 매개 변수 이름은 UriTemplate에 지정된 매개 변수와 동일한 이름을 지정해야합니다. 원래

:

<OperationContract()> 
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="ValidateLogin/{e}/{p}")> 
Function ValidateLogin(ByVal sEmailAddress As String, ByVal sPassword As String) As List(Of CheckLogin) 

수정 :

<OperationContract()> 
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped, UriTemplate:="ValidateLogin/{e}/{p}")> 
Function ValidateLogin(ByVal e As String, ByVal p As String) As List(Of CheckLogin) 
관련 문제