나는 최신 Nuget 패키지를 사용하여 구성된 매우 간단한 ServiceStack 웹 서비스를 가지고 있습니다 (3.8.3 믿습니다). 내가 변경 한 주요 변경 사항은 호출 클라이언트가 응답 메시지를 지원하면 ResultContext.ToOptimizedResult(object)
에 응답 메시지를 압축하도록 호출하는 것이 었습니다.Servicestack SOAP 및 ToOptimizedResult 클라이언트 구문 분석 오류
var jsonClient = new JsonServiceClient("http://localhost/WebAppServiceV3/api");
var response = jsonClient.Send<PingResponse>(new Ping { LoginInfo = new ClientLoginInfo { UserName = "guest", Password = "guest", ClientPlatform = "TEST", ClientVersion = "1.3", InstanceUID = Guid.NewGuid().ToString() } });
Console.WriteLine(response.ToJson() + "\n");
var jsvClient = new JsvServiceClient("http://localhost/WebAppServiceV3/api");
response = jsvClient.Send<PingResponse>(new Ping { LoginInfo = new ClientLoginInfo { UserName = "guest", Password = "guest", ClientPlatform = "TEST", ClientVersion = "1.3", InstanceUID = Guid.NewGuid().ToString() } });
Console.WriteLine(response.ToJsv() + "\n");
var xmlClient = new XmlServiceClient("http://localhost/WebAppServiceV3/api");
response = xmlClient.Send<PingResponse>(new Ping { LoginInfo = new ClientLoginInfo { UserName = "guest", Password = "guest", ClientPlatform = "TEST", ClientVersion = "1.3", InstanceUID = Guid.NewGuid().ToString() } });
Console.WriteLine(response.ToXml() + "\n");
var soap11 = new Soap11ServiceClient("http://localhost/WebAppServiceV3/api");
response = soap11.Send<PingResponse>(new Ping { LoginInfo = new ClientLoginInfo { UserName = "guest", Password = "guest", ClientPlatform = "TEST", ClientVersion = "1.3", InstanceUID = Guid.NewGuid().ToString() } });
Console.WriteLine(response.ToXml() + "\n");
var soap12 = new Soap12ServiceClient("http://localhost/WebAppServiceV3/api");
response = soap12.Send<PingResponse>(new Ping { LoginInfo = new ClientLoginInfo { UserName = "guest", Password = "guest", ClientPlatform = "TEST", ClientVersion = "1.3", InstanceUID = Guid.NewGuid().ToString() } });
Console.WriteLine(response.ToXml() + "\n");
json으로, JSV 및 XML 클라이언트 모두 압축 여기에 응답 및 작업 벌금을받을 다음과 같이
public class PingService : BaseService<Ping>
{
protected override string OperationName { get { return "Ping"; } }
protected override object Run(Ping request)
{
// Implementation removed for brevity
return new PingResponse();
}
protected override object OnAfterExecute(object response)
{
//return response;
return RequestContext.ToOptimizedResult(response);
}
}
클라이언트 코드는 다음과 같이 서비스 정의된다. 비누 클라이언트는 대신 return ResultContext.ToOptimizedResult(result)
줄이 서비스에 포함될 때 예외를 throw합니다.
그것은 클라이언트가 <PingResponse/>
요소를 기대하지만, 압축 된 결과가 반환 될 때 <Base64Binary/>
요소 대신받는 것 같다 :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<base64Binary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">...</base64Binary>
</s:Body>
</s:Envelope>
압축 해제를
이Error in line 1 position 185. Expecting element 'PingResponse' from namespace 'http://schemas.datacontract.org/2004/07/IMDSSWebService_SS.ServiceModel'.. Encountered 'Element' with name 'base64Binary', namespace 'http://schemas.microsoft.com/2003/10/Serialization/'.
압축에 (실패) (성공)
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<PingResponse>...<PingResponse>
</s:Body>
</s:Envelope>
임의의 insig ht 내가 여기서 잘못하고있는 것일 수 있습니까? 미리 감사드립니다.
이protected PingResponse Run(Ping request)
{
// Implementation removed for brevity
return new PingResponse();
}
(예를 들어, 당신은 반환 형식으로 object
을 사용할 수 없습니다
https://github.com/ServiceStack/ServiceStack/issues/183에서 생성 된 문제입니다. 감사합니다 mythz – pseabury