Change the default namespace of a SOAP service entry xml in C#

36 Views Asked by At

The problem I have is that in the xml provided by the provider, the namespace looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<pgim:Document xmlns:pgim="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.06.031"   
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.06.031 pacs.008.031.xsd ">

While mine when running the service looks like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

I have a soap service whose soap service I generated with the XSD tool from the VS terminal, the initial part of the code that I do not include in full because it is very long is this:

using System.Xml.Serialization;

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08.031")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08.031", IsNullable = false)]
public partial class Document : System.Web.Services.Protocols.SoapHeader
{
    private HeaderData headerField;
    private FIToFICustomerCreditTransferV06 fIToFICstmrCdtTrfField;

    /// <remarks/>
    public HeaderData Header {
        get {
            return this.headerField;
        }
        set {
            this.headerField = value;
        }
    }
    
    /// <remarks/>
    public FIToFICustomerCreditTransferV06 FIToFICstmrCdtTrf {
        get {
            return this.fIToFICstmrCdtTrfField;
        }
        set {
            this.fIToFICstmrCdtTrfField = value;
        }
    }

}

And then I use it as input data in the asmx service created, like this:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la línea siguiente. 
// [System.Web.Script.Services.ScriptService]
public class Transfer: System.Web.Services.WebService
{
    public ModelTransfer.Document entry = new ModelTransfer.Document();
    
    [WebMethod]
    [SoapHeader("entry")]
    public ModelTransfer.Output Consulta()
    {
        ModelTransfer.Output output = new ModelTransfer.Output();

        return output;
    }
}
0

There are 0 best solutions below