0

I am trying to submit data through a SOAP request. The data received in the web service is null, presumably because the blank xmlns namespace in the XML that I am sending causes the the data to return null (e.g. the TransmissionVersion). Most of the online resources recommend removing xmlns = "", but is there a quick way to make the service accept the namespace without having to inspect it and remove it before the request is sent, as is done here?

https://cmatskas.com/changing-soap-message-data-and-namespaces-with-c/

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:efil="http://samplelink.org" xmlns="http://samplelink.org">
   <soapenv:Header/>
   <soapenv:Body>
        <Send xmlns="http://samplelink.org">
            <Transmission>
                <SimplifiedReturnTransmission transmissionVersion="2015V01" xmlns="">
                    <TransmissionHeader>
                        <TransmissionId>TI000024691218803</TransmissionId>
                        <Timestamp>2014-09-07T10:18:26</Timestamp>
                        <Transmitter>
                            <ETIN>67666665</ETIN>
                        </Transmitter>
                        <ProcessType>T</ProcessType>
                        <DocumentCount>1</DocumentCount>
                        <TransmissionPaymentHash>14022.49</TransmissionPaymentHash>
                    </TransmissionHeader>                   
                </SimplifiedReturnTransmission>
            </Transmission>
        </Send>
    </soapenv:Body>
</soapenv:Envelope>

Here's the relevant code from the interface:

<DataContract()>
<System.Xml.Serialization.XmlRootAttribute("SimplifiedReturnTransmission")>
Public Class SimplifiedReturnTransmissionType
    Private transmissionHeaderField As TransmissionHeaderType
    Private simplifiedReturnDocumentField() As SimplifiedReturnDocumentType  
    Private transmissionVersionField As String

    <DataMember(EmitDefaultValue:=False)>
    <System.Xml.Serialization.XmlElementAttribute("TransmissionHeader")>
    Public Property TransmissionHeader() As TransmissionHeaderType
        Get
            Return Me.transmissionHeaderField
        End Get
        Set(ByVal value As TransmissionHeaderType)
            Me.transmissionHeaderField = value
        End Set
    End Property

    <DataMember(EmitDefaultValue:=False)> <System.Xml.Serialization.XmlAttributeAttribute()>
    Public Property transmissionVersion() As String
        Get
            Return Me.transmissionVersionField
        End Get
        Set(ByVal value As String)
            Me.transmissionVersionField = value
        End Set
    End Property
End Class
nesco88
  • 35
  • 2
  • 9
  • Try using `svcutil.exe` to generate a proxy for you and then you can either use the generated classes or at least will be able to see the attribute values you need to use in your own code. – Alex Seleznyov Sep 21 '17 at 09:31
  • svcutil.exe didn't work, but I tried using xsd.exe and it didn't work. The only difference in attribute values I saw was that this Form:=System.Xml.Schema.XmlSchemaForm.Qualified showed up after a few attributes had been declared, but even putting those in changed nothing. – nesco88 Sep 21 '17 at 18:07
  • Additionally, there are instances of [Namespace]:="", IsNullable:=false in the XmlRootAttributes of the auto-generated vb files, but they throw an error when attempting to run in the service. – nesco88 Sep 21 '17 at 19:23
  • What was the svcutil's error? If source wsdl has included .xsd files you need them alongside wsdl. – Alex Seleznyov Sep 22 '17 at 08:04
  • We did this but we found that the service would not accept a blank namespace on a root attribute, qualified or not. We had to make the parent element a root instead. – nesco88 Sep 22 '17 at 19:02
  • Can you please add wsdl of the service you are trying to connect to? – Alex Seleznyov Sep 22 '17 at 19:36
  • We resolved the issue. See posted answer. Thanks for your help. – nesco88 Sep 25 '17 at 15:13

1 Answers1

0

Making the element with a blank namespace on it an ElementAttribute rather than a RootAttribute resolved the issue. The parent of that element became a root attribute instead.

<System.Xml.Serialization.XmlElementAttribute("SimplifiedReturnTransmission")>

<System.Xml.Serialization.XmlRootAttribute("Transmission", [Namespace]:="", IsNullable:=False)>
nesco88
  • 35
  • 2
  • 9