에 게시 할 때 xml 내용이 손실되어 게시물을 통해 wcf 서비스를 호출 할 때 xml 내용이 손실됩니다. 나는 wcf 방법에만 "<"을 참조하십시오. xml 콘텐츠를 다음과 같이 전달하고 있습니다 : samplesample.POST를 wcf REST
클라이언트 :
jQuery.support.cors = true;
$.ajax({
type: 'POST',
url: 'http://localhost:48677/MYSVC.svc/ParseXML/<?xml version=1.0 encoding=UTF-8?><node>sample</node><node1>sample</node1>',
cache: false,
contentType: 'text/xml;charset=UTF-8',
dataType: 'json',
processData: true,
success: function (msg) {
},
error: function (err) {
}
});
서비스 인터페이스 :
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "ParseXML/{xmlContent}")]
Stream ParseXML(string xmlContent);
또한 통합 래퍼에 따라 : 나는 비 XML 문자열을 전달하면 http://vivekcek.wordpress.com/2012/06/14/wcf-rest-service-accepting-raw-xml-webcontenttypemapper/
, 내 서비스를 호출하지만 적절한 취득 XML 콘텐츠가 아닙니다.
모두 서비스 &의 asp.net의 web.config에서도 포함 다음 행
<httpRuntime requestValidationMode="2.0" maxUrlLength="4096" requestPathInvalidCharacters="" useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647" requestLengthDiskThreshold="2147483647" executionTimeout="18000" targetFramework="4.5"/>
내가이 함께 노력 : requestPathInvalidCharacters = "<, >, *, % : \,?" 하지만 도움이되지 않았다
wcf에 적절한 xml 콘텐츠를 전달하는 방법을 안내해주세요!
업데이트 :
오류 아래 얻고, HttpWebResponse 클래스에서 서비스를 호출하는 동안 :
The server encountered an error processing the request. The exception message is 'Incoming message for operation 'ParseXML' (contract 'IXmlParseService' with namespace ' http://tempuri.org/ ') contains an unrecognized http body format value 'Xml'. The expected body format value is 'Raw'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is:
at System.ServiceModel.Dispatcher.HttpStreamFormatter.GetStreamFromMessage(Message message, Boolean isRequest) at System.ServiceModel.Dispatcher.HttpStreamFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
아약스를 통해 호출하면 encodeURIComponent 없이도 작동합니다. 원래 질문의 업데이트 된 오류 메시지를 참조하십시오. – user1480864
서비스 구성에 정의 된 xml에 대한 적절한 webHttpBinding 및 서비스 동작을 가지고 있습니까? –