0

Please I need change the FORMULARIO'S Prefix (Tem: TO Men1:) from this XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:men="http://Mensajes.General.inHeader" xmlns:tem="http://tempuri.org/" xmlns:men1="http://Mensajes.Formularios.Guardar">
   <soapenv:Header>
      <men:inHeader>
         <DSUSUARIO></DSUSUARIO>
         <PWDUSUARIO></PWDUSUARIO>
      </men:inHeader>
   </soapenv:Header>
   <soapenv:Body>
      <tem:Guardar> <!--OperationContract-->
         <tem:FORMULARIO> <!--DataContract-->
         </tem:FORMULARIO>
      </tem:Guardar>
   </soapenv:Body>
</soapenv:Envelope>

The problem is that i can't set a Namespace to OperationContract to override the Namespace Base. In this chase the OperationContract is the parent from DataContract at Xml.

My code is:

[ServiceContract(Namespace = "http://tempuri.org/")]
public interface IComportamiento
{
[OperationContract]
[XmlSerializerFormat]
Resultado Guardar(FORMULARIO FORMULARIO);
}

public class Implementacion : IComportamiento
{
public Resultado Guardar(FORMULARIO FORMULARIO)
{
...
}
}

[DataContract]
public class FORMULARIO
{
}

1 Answers1

0

MessageContract could change the Root element's namespace but it will remove operationcontract's element , also the return type should also be changed to FORMULARIO.

[ServiceContract(Namespace = "http://tempuri.org/")]

public interface IComportamiento
{
    [OperationContract]

    FORMULARIO Guardar(FORMULARIO FORMULARIO);
}

[MessageContract(IsWrapped = true, WrapperName = "FORMULARIO", WrapperNamespace = "http://Mensajes.Formularios.Guardar")]
public class FORMULARIO
{

}

The result. enter image description here

Ackelry Xu
  • 756
  • 3
  • 6
  • Thanks for response, ok i did that you told me, but i can't change the structure because the client needs, so i created a class Guardar with Namespace="http://tempuri.org/" and IsWrapped="True" Attributes, And FORMULARIO as Property, Then Guardar Class is passed through the OperationContract As Param. – Sebastian Reyes Apr 27 '19 at 13:48