WCF를 사용하여 외부 (즉, 계약을 제어 할 수 없음) REST 서비스를 호출하려고한다고 상상해보십시오. 나는이WCF UriTemplate UrlEncode
[ServiceContract]
public interface ISomeRestApi
{
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "blablabla/{parameter1}/{parameter2}")]
void PutSomething(string parameter1, string parameter2);
}
내 매개 변수 중 하나는 슬래시 (/) 내 UriTemplate 경로 매개 변수를 urlencode WCF를 강제로 어떻게
public class Test{
[Fact]
public void TestPutSomething()
{
ISomeRestApi api = CreateApi();
//this results in the url: http://server/blablabla///someotherparam
api.PutSomething("/", "someotherparam");
//this also results in the url: http://server/blablabla///someotherparam
api.PutSomething(HttpUtility.UrlEncode("/"), "someotherparam");
//but i want: http://server/blablabla/%2F/someotherparam
}
}
이라고 말할 다음 계약?
[가능한 슬래시 및 다른 'URL 민감한'문자를 WCF REST 서비스에 전달할 수 있습니까?] (http://stackoverflow.com/questions/7176726/how-can-i-pass-slash-and) -other-url-sensitive-characters-to-a-wcf-rest-service) –
호출 된 외부 서비스를 제어 할 수 없어 링크 된 질문의 대답은이 질문에 대한 유효한 대답이 아닙니다. 서비스 계약에있는 uritemplate은 불가능합니다. 이 제약 조건을 반영하도록 질문을 수정했습니다. – Stif