post 메서드를 사용하여 나머지 서비스를 호출 할 수없고 끝점을 찾을 수없는 오류가 계속 발생합니다. 코드 여기 아래 :WCF Rest service post 메서드가 끝 점이 없음
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(
Method = "POST",
UriTemplate = "GetData",
BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json
)]
string GetData(string value);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Service1 : IService1
{
public string GetData(string value)
{
return value;
}
}
의 Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxUrlLength="1048576" relaxedUrlToFileSystemMapping="true" />
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" />
</protocolMapping>
<services>
<service name="RestPost.Service1" behaviorConfiguration="default">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="RestPost.IService1" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web" >
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<!-- default binding configration used for all REST services -->
<webHttpBinding>
<!-- max allowed message size incresed to 500 000 Bytes -->
<binding maxBufferSize="95000000" maxReceivedMessageSize="95000000" />
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxUrl="40960000" maxQueryString="20480000" maxAllowedContentLength="20480000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
이 내가 브라우저에서 URL을
http://localhost:57395/Service1.svc/getdata/large base64encoded string here
이 내가 피들러 에서 호출하는 방법입니다 호출하고 어떻게
저는 Casini에서 이것을 실행하려고합니다. 결국 IIS 7.5에 배포됩니다.
큰 base64 인코딩 문자열을 전달하는 이유가 궁금한 경우 JSON 형식으로 요청을 게시해야하므로이 작업을 수행하고 있습니다. 이제 JSON에는 IIS가 즉시 거부하는 특수 문자가 있기 때문에 URLencode를 사용해 보았습니다. 이 문제는 1000자를 넘는 수는 없다는 것입니다. 길이에 제한이 있습니다. Base64 인코딩과 포스트 사용이 유일한 방법이었습니다. 그래서 나는이 코드를 사용할 것입니다.
이 서비스의 원래 목표는이 서비스에 대한 JSON 게시를 만들고 그에 대한 응답으로 JSON 응답을받을 자바 스크립트 기반 클라이언트를 제공하는 것입니다. xml 문자열 패딩이없는 순수한 JSON 응답입니다.
나머지 서비스에 게시물을 가져 오는 데 도움이 필요합니다.
실제로 입력베이스 매개 변수를 입력하기 위해 필자는 문자열을 Stream으로 변경해야하며 피들러에서 테스트했을 때 작동했습니다. 콘텐츠 유형을 "application/x-www-form-urlencoded"그대로 두었습니다. 당신은 브라우저가 게시판이 아니라 게시판을 만드는 것에 맞습니다. – user20358
맞습니다. [원시 프로그래밍 모델] (http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data)을 사용할 수도 있습니다. aspx)를 사용하여 양식에서 인코딩 된 임의의 데이터를 수신 할 수 있습니다. – carlosfigueira