구성이 잘못되었습니다. 암호로 보호 된 보안을 IIS (아직 성취되지 않음)로 감싸려고하고 있는데 모든 종류의 예외가 발생합니다. 이번에는 보안 토큰이 잘못되었거나 잘못된 요소 예외가 발생합니다.보안을위한 WCF 구성이 작동하지 않음 : Throwing 보안 토큰에 대한 요청에 잘못되었거나 형식이 잘못된 요소가 있습니다.
이HOST :
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name ="WSHttpBinding_ISVC1">
<security mode="Message">
<message clientCredentialType="UserName" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SVCBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="blahblah.SVCValidator, TrademarkGlobal.Web"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="blahblah.SVC"
behaviorConfiguration="SVCBehaviors">
<endpoint address="" binding="wsHttpBinding"
contract="blahblah.ISVC" name="WSHttpBinding_ISVC1"/>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding" address="mex"/>
</service>
</services>
</system.serviceModel>
</configuration>
CLIENT:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ISVC1">
<security mode="Message">
<message clientCredentialType="UserName" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:64609/SVC.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ISVC1" contract="ISVC">
</endpoint>
</client>
</system.serviceModel>
SVC 파일 (svc.svc) :
<%@ServiceHost Service="blahblah.SVC" %>
본 서비스 (SVC & ISVC)이 지금의 기본 strin g를 돌려 여기 내 CONFIGS 있습니다.
SVCVALIDATOR.cs : 실행하는 데 사용
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.IdentityModel.Selectors;
public class SVCValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (userName == null || password == null)
{
throw new ArgumentNullException();
}
if (userName != "gooduser" && password != "goodpass")
{
throw new Exception("Incorrect Username or Password");
}
}
}
컨트롤러 액션 :
public class SVCController : Controller
{
public ActionResult Index(string user = "bad", string pass = "bad")
{
using (SVCClient client = new SVCClient())
{
//SVCClient client = new SVCClient("WSHttpBinding_ISVC");
client.ClientCredentials.UserName.UserName = user;
client.ClientCredentials.UserName.Password = pass;
ViewBag.Message = client.Test();
return View("RunningSVC");
}
}
}
나는이 오류가 기본적으로 서버를 컴파일 할 수 없다고 생각한다. 실제 오류 메시지를 보려면 * blahblah.SVC * 서비스의 URL로 이동하십시오. 거기에 뭐가 보이니? – McGarnagle