WCF 서비스를 사용하고 "원격 서버에서 오류 (400) 요청이 잘못되었습니다."라는 오류 메시지가 나타납니다. 웹 클라이언트를 통해 소모 할 때 다음과 같이webclient를 통해 호출되는 WCF 메서드 - HTTP 400 - 잘못된 요청
public class WebClientService : WebClient
...
base.Credentials = CredentialCache.DefaultCredentials;
base.OpenReadCompleted += new OpenReadCompletedEventHandler(ReadJsonStringAsyncComplete);
base.OpenReadAsync(new Uri("http://localhost/xxxx.svc/GetData"));
...
소비하는 WCF 서비스 (둘 다 (다른 프로젝트)
계약/인터페이스 동일한 솔루션 내에 존재하는주의입니다 : -
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
IList<MyType> GetData();
구현 -
public IList<MyType> GetData()
{
return (new MyTypeRepository()).All.ToList();
}
구성 : -
나는 HTTP를 얻을 왜사람이 알고 있나요 - 나는 방법 GetData의를 호출 할 수없는 것 그러나
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="xxxx.Service.MyService" behaviorConfiguration="DataExtractBehavior">
<endpoint address="http://localhost:1422/MyService.svc" binding="webHttpBinding" bindingConfiguration="DataExtractBinding" behaviorConfiguration="MyEndpointBehavior" contract="xxxx.Service.Common.IMyService"></endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="MyEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles" />
<serviceCredentials>
<windowsAuthentication allowAnonymousLogons="false" includeWindowsGroups="true" />
</serviceCredentials>
</behavior>
<behavior name="DataExtractBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<etwTracking profileName="EndToEndMonitoring Tracking Profile" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<etwTracking profileName="EndToEndMonitoring Tracking Profile" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="DataExtractBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
내가 http://localhost:1422/xxxx.svc
를 통해 서비스 정의 페이지를 볼 수 있습니다 (http://localhost:1422/xxxx.svc/GetData
URI에의 마지막에 추가) 400 - 잘못된 요청
많은 감사 트래비스
감사 계약을 체결 한 위의 서비스에 "포스트"요청을했다 -이 문제 –
를 해결하는 데 도움 @ TravisIngram, 당신은 환영합니다 :). 나는 "Post"& "Get"을 알지 못했다. :) –