우리는 우리의 고객이 소비하는 기존 웹 서비스를 대체 할 웹 서비스를 개발하려고합니다. 즉, WCF의 새 웹 서비스의 SOAP 응답은 Java로 작성된 레거시 서비스 인 현재 웹 서비스의 SOAP 응답과 정확하게 일치해야합니다. 새 서비스가 이전 서비스와 동일한 SOAP 응답을 반환하도록 만드는 데 문제가 있습니다.WCF 서비스의 SOAP 포맷
처음에는 응답 구조로 DataContract를 시작했지만 MessageContract로 전환 한 일부 추가 태그를 생성하기 시작했습니다.
다음은 요청 및 응답의 특성으로 DataContAract를 사용한 샘플 요청 및 응답입니다. 우리가 프로그램 제거 할 수없는 어떤
응답은 두 개의 추가 태그
GetDataUsingDataContractReponse
,GetDataUsingDataContractResult
을 가지고있다 - 우리는 DataContract를 사용하여 문제의 두 직면하고있다.BoolValue
속성을 XML 특성으로 가져올 수 없으며 대신 XML 요소로 나타납니다.
이 두 가지 문제를 해결할 수있는 아이디어를 공유해 주시면 대단히 감사하겠습니다. 다음은 DataContract
을 사용한 샘플 요청 및 응답입니다. DataContract와 DataContract-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:mem="http://schemas.datacontract.org/2004/07/MemoPayment">
<soapenv:Header/>
<soapenv:Body>
<tem:GetDataUsingDataContract>
<!--Optional:-->
<tem:composite>
<mem:BoolValue>true</mem:BoolValue> <!--Not able to make this value as XML Attribute. Instead, always shows up as XML Element -->
<mem:StringValue>Sam</mem:StringValue>
</tem:composite>
</tem:GetDataUsingDataContract>
</soapenv:Body>
</soapenv:Envelope>
응답
요청 :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetDataUsingDataContractResponse xmlns="http://tempuri.org/">
<GetDataUsingDataContractResult xmlns:a="http://schemas.datacontract.org/2004/07/MemoPayment" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> à Extra tags showing up. Any way to remove them?
<a:BoolValue>true</a:BoolValue>
<a:StringValue>SamSuffix</a:StringValue>
</GetDataUsingDataContractResult>
</GetDataUsingDataContractResponse>
</s:Body>
</s:Envelope>
은 SOAP 메시지에 대한 제어를 가지고, 우리는 MessageContract
에 DataContract
로 전환하고 현재의 응답은 다음과 같이 표현되고 XML 속성 및 XML 요소가 필요합니다.
그러나 MessageContract
을 사용하면 모든 XML 요소가 선택 사항으로 표시된다는 점이 문제입니다. 예 - 아래 요청의 StringValue
. 다시 한번 말하지만, 우리는 당신의 경험에서 어떤 일을 제안 할 수 있다면 크게 감사 할 것입니다. MessageContract와
요청 : MessageContract와
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:MsgRequest boolVal="true">
<!--Optional:-->
<tem:StringValue>Sam</tem:StringValue> à Always showing up as Optional. Not able to control from the code. Any way to remove the Optional attribute?
</tem:MsgRequest>
</soapenv:Body>
</soapenv:Envelope>
응답 : 과거
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MsgResponse boolVal="true" xmlns="http://tempuri.org/">
<StringValue>SamSuffix</StringValue>
</MsgResponse>
</s:Body>
</s:Envelope>