0
  Using response As WebResponse = request.GetResponse()
            Using rd As New StreamReader(response.GetResponseStream())
                Dim soapResult As String = rd.ReadToEnd()
                SerializeCollection(soapResult)

the soapResult generate the following :

  <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <SOAP-ENV:Body>
  <createShipmentResponse xmlns="http://www.royalmailgroup.com/api/ship/V2">
     <integrationHeader>
        <dateTime xmlns="http://www.royalmailgroup.com/integration/core/V1">2016-03-23T06:55:32</dateTime>
        <version xmlns="http://www.royalmailgroup.com/integration/core/V1">2</version>
        <identification xmlns="http://www.royalmailgroup.com/integration/core/V1">
           <applicationId>RMG-API-G-01</applicationId>
           <transactionId>730222611</transactionId>
        </identification>
     </integrationHeader>
     <integrationFooter>
        <errors xmlns="http://www.royalmailgroup.com/integration/core/V1">
           <error>
              <errorCode>E1105</errorCode>
              <errorDescription>The countryCode specified is not valid</errorDescription>
           </error>
           <error>
              <errorCode>E1001</errorCode>
              <errorDescription>Postcode AA9 0AA invalid</errorDescription>
           </error>
        </errors>
        <warnings xmlns="http://www.royalmailgroup.com/integration/core/V1">
           <warning>
              <warningCode>W0036</warningCode>
              <warningDescription>E-mail option not selected so e-mail address will be ignored</warningDescription>
           </warning>
           <warning>
              <warningCode>W0035</warningCode>
              <warningDescription>SMS option not selected so Telephone Number will be ignored</warningDescription>
           </warning>
        </warnings>
     </integrationFooter>
      </createShipmentResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

i am using this method to serialize this response :

Private Sub SerializeCollection(filename As String)
    Dim Emps As createShipmentResponse = New createShipmentResponse()
    ' Note that only the collection is serialized -- not the 
    ' CollectionName or any other public property of the class.
    Dim x As XmlSerializer = New XmlSerializer(GetType(createShipmentResponse))
    Dim writer As TextWriter = New StreamWriter(filename)
    x.Serialize(writer, Emps)
    writer.Close()
End Sub

but i am having this error : Illegal characters in path what does that mean ? and how can i fix this ?

Sora
  • 2,465
  • 18
  • 73
  • 146

1 Answers1

0

Your SerializeCollection() method expects a file path to serialize to a file. You're currently passing the contents of your response which is why it doesn't work.

If you haven't written the method yourself I think you've not found completely what you're looking for.

This is an example of how the method should be called:

SerializeCollection("C:\Users\Vincent\Desktop\Hello.bin") 'The extension doesn't need to be '.bin', but it's an example.

The method has currently no way of getting your response, for that you should add a second parameter.

As I'm not familiar with Soap serialization I'm afraid I cannot help you further.

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
  • Perhaps [this question](http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document) could give you what you need. – Visual Vincent Mar 23 '16 at 07:40
  • i did put the response i am getting in a seperate testfile.xml and i tried to use the function as u said in your answer but the same error is returned – Sora Mar 23 '16 at 07:40
  • @Sora : Are you inputting a correct path? The method has no way of getting your data you know that, right? --- On what line do you get your error? – Visual Vincent Mar 23 '16 at 07:42
  • i tired to get `soapresult` string save it in a file using a `file.create` then use the `SerializeCollection` and delete the file when finish and it worked but this is a buggy not reliable idea :/ – Sora Mar 23 '16 at 07:58
  • @Sora : But the XML you get already seems to be serialized. Are you attempting to serialize it again? – Visual Vincent Mar 23 '16 at 08:17