Как удалить посторонний узел XML, который оборачивает мой объект в конверт Soap? - PullRequest
0 голосов
/ 28 июня 2019

Я потратил слишком много времени на это, поэтому пришло время сократить свои потери и выполнить публикацию на SO.

Рассматриваемый сервис - это конечная точка WCF .NET 4.7.2, написанная на C #,Возможны следующие варианты:

Целевое пространство имен

public const string AcordNamespace = "http://ACORD.org/Standards/Life/2";

ServiceContract

[XmlSerializerFormat]
[ServiceContract(Name = "PolicyAdministrationPort", Namespace = Constants.AcordNamespace)]
public interface IPolicyAdministration
{
    [OperationContract]
    [return: MessageParameter(Name = "TXLife")]
    Task<TXLife_Type> StraightThroughCyberlife([MessageParameter(Name = "TXLife")] TXLife_Type request);
}

ServiceBehavior

[ServiceBehavior(Namespace = Constants.AcordNamespace)]
public class PolicyAdministration : IPolicyAdministration
{
    public async Task<TXLife_Type> StraightThroughCyberlife(TXLife_Type request)
    {

    }
}

TXLife_Type

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3190.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://ACORD.org/Standards/Life/2")]
[System.Xml.Serialization.XmlRootAttribute("TXLife", Namespace = "http://ACORD.org/Standards/Life/2", IsNullable = false)]
public partial class TXLife_Type : EntityBase<TXLife_Type>
{

}

WSDL

    <wsdl:definitions 
    name="PolicyAdministration" 
    targetNamespace="http://ACORD.org/Standards/Life/2" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
    xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
    xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="http://ACORD.org/Standards/Life/2" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <wsdl:types>
    <xsd:schema targetNamespace="http://ACORD.org/Standards/Life/2/Imports">
    <xsd:import schemaLocation="http://localhost/StraightThroughCyberLife.Web/PolicyAdministration.svc?xsd=xsd0" namespace="http://ACORD.org/Standards/Life/2"/>
    </xsd:schema>
    </wsdl:types>
    <wsdl:message name="PolicyAdministrationPort_StraightThroughCyberlife_InputMessage">
    <wsdl:part name="parameters" element="tns:StraightThroughCyberlife"/>
    </wsdl:message>
    <wsdl:message name="PolicyAdministrationPort_StraightThroughCyberlife_OutputMessage">
    <wsdl:part name="parameters" element="tns:StraightThroughCyberlifeResponse"/>
    </wsdl:message>
    <wsdl:portType name="PolicyAdministrationPort">
    <wsdl:operation name="StraightThroughCyberlife">
    <wsdl:input wsaw:Action="http://ACORD.org/Standards/Life/2/PolicyAdministrationPort/StraightThroughCyberlife" message="tns:PolicyAdministrationPort_StraightThroughCyberlife_InputMessage"/>
    <wsdl:output wsaw:Action="http://ACORD.org/Standards/Life/2/PolicyAdministrationPort/StraightThroughCyberlifeResponse" message="tns:PolicyAdministrationPort_StraightThroughCyberlife_OutputMessage"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="PolicyAdministrationEndpoint" type="tns:PolicyAdministrationPort">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="StraightThroughCyberlife">
    <soap:operation soapAction="http://ACORD.org/Standards/Life/2/PolicyAdministrationPort/StraightThroughCyberlife" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="PolicyAdministration">
    <wsdl:port name="PolicyAdministrationEndpoint" binding="tns:PolicyAdministrationEndpoint">
    <soap:address location="http://localhost/StraightThroughCyberLife.Web/PolicyAdministration.svc"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

Мыльный конверт

    <soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:ns="http://ACORD.org/Standards/Life/2">
     <soapenv:Header/>
     <soapenv:Body>
        <ns:StraightThroughCyberlife> <!-- WHY IS THIS WRAPPING MY TXLife? -->
           <!--Optional:-->
           <ns:TXLife Version="?">
             <!-- 450,000 lines of code removed... I wish it wasn't true -->
           </ns:TXLife>
        </ns:StraightThroughCyberlife>
     </soapenv:Body>
    </soapenv:Envelope>

Конечная цель

    <soap:Envelope">
      <soap:Body">
        <TXLife xmlns="http://ACORD.org/Standards/Life/2>
          <TXLifeRequest>
            <TransRefGUID></TransRefGUID>
            <TransType tc="103">
            </TransType>
            <TransSubType tc="12345"></TransSubType>
          </TXLifeRequest>
        <TXLife>
      </soap:Body>
    </soap:Envelope">

Моя цель - сделать этот Acord-совместимый, но это зависит от очистки мыльной оболочки, как продемонстрированопоследний мыльный конверт.Если у вас также есть лучшее название, пожалуйста, дайте мне знать, и я обновлю его.

Спасибо, Стивен

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...