title: Solved ! Error reading XMLStreamReader: Unexpected character SOAP API
body: <p>I'm trying to communicate with SOAP API <code>https://www.flussituristici.servizirl.it/Turismo5/app/ws/checkinV1?wsdl</code>
  using Savon gem.</p>
  
  <p>so far I've implemented following code:</p>
  
  <pre><code>  def client
      client = Savon.client(
        wsdl: "https://www.flussituristici.servizirl.it/Turismo5/app/ws/checkinV1?wsdl",
        host: "https://www.flussituristici.servizirl.it/Turismo5/app/ws/checkinV1",
        soap_header: { 'Authorization:' =&gt; "Basic #{Base64.strict_encode64("username: password")}"},
        log: true,
        pretty_print_xml: true
      )
      client.call(:invia_movimentazione, message: message, soap_action: '')
    end
  
    def message
      {
        movimenti:
        {
          codice: "S00352",
          prodotto: "XXXXX",
          movimento:
          [
            {
              data: "20190911",
              struttura:
                {
                  apertura: "SI",
                  camereoccupate: "10",
                  cameredisponibili: "16",
                  lettidisponibili: "34"
                }
            },
            {
              data: "20190911",
              struttura:
              {
                apertura: "SI",
                camereoccupate: "9",
                cameredisponibili: "16",
                lettidisponibili: "34"
              }
            }
          ]
        }
      }
    end 
  </code></pre>
  
  <p>but i'm getting following error response:</p>
  
  <pre><code>D, [2019-09-11T06:45:28.544608 #12024] DEBUG -- : HTTPI /peer GET request to www.flussituristici.servizirl.it (net_http)
  I, [2019-09-11T06:45:29.557382 #12024]  INFO -- : SOAP request: https://www.flussituristici.servizirl.it/Turismo5/app/ws/checkinV1
  I, [2019-09-11T06:45:29.562181 #12024]  INFO -- : SOAPAction: "", Content-Type: text/xml;charset=UTF-8, Content-Length: 925
  D, [2019-09-11T06:45:29.576008 #12024] DEBUG -- : &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://checkin.ws.service.turismo5.gies.it/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;env:Header&gt;
      &lt;Authorization:&gt;Basic TUk0OTg1231d01kTmNXKkp2N3I123&lt;/Authorization:&gt;
    &lt;/env:Header&gt;
    &lt;env:Body&gt;
      &lt;tns:inviaMovimentazione&gt;
        &lt;movimenti&gt;
          &lt;codice&gt;S00352&lt;/codice&gt;
          &lt;prodotto&gt;XXXXX&lt;/prodotto&gt;
          &lt;movimento&gt;
            &lt;data&gt;20190911&lt;/data&gt;
            &lt;struttura&gt;
              &lt;apertura&gt;SI&lt;/apertura&gt;
              &lt;camereoccupate&gt;10&lt;/camereoccupate&gt;
              &lt;cameredisponibili&gt;16&lt;/cameredisponibili&gt;
              &lt;lettidisponibili&gt;34&lt;/lettidisponibili&gt;
            &lt;/struttura&gt;
          &lt;/movimento&gt;
          &lt;movimento&gt;
            &lt;data&gt;20190911&lt;/data&gt;
            &lt;struttura&gt;
              &lt;apertura&gt;SI&lt;/apertura&gt;
              &lt;camereoccupate&gt;9&lt;/camereoccupate&gt;
              &lt;cameredisponibili&gt;16&lt;/cameredisponibili&gt;
              &lt;lettidisponibili&gt;34&lt;/lettidisponibili&gt;
            &lt;/struttura&gt;
          &lt;/movimento&gt;
        &lt;/movimenti&gt;
      &lt;/tns:inviaMovimentazione&gt;
    &lt;/env:Body&gt;
  &lt;/env:Envelope&gt;
  
  D, [2019-09-11T06:45:29.580471 #12024] DEBUG -- : HTTPI /peer POST request to www.flussituristici.servizirl.it (net_http)
  I, [2019-09-11T06:45:30.455910 #12024]  INFO -- : SOAP response (status 500)
  D, [2019-09-11T06:45:30.457178 #12024] DEBUG -- : &lt;?xml version="1.0"?&gt;
  &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
      &lt;soap:Fault&gt;
        &lt;faultcode&gt;soap:Client&lt;/faultcode&gt;
        &lt;faultstring&gt;Error reading XMLStreamReader: Unexpected character '&amp;gt;' (code 62) (expected a name start character)
   at [row,col {unknown-source}]: [1,289]&lt;/faultstring&gt;
      &lt;/soap:Fault&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  
  Savon::SOAPFault: (soap:Client) Error reading XMLStreamReader: Unexpected character '&gt;' (code 62) (expected a name start character)
   at [row,col {unknown-source}]: [1,289]
  from /usr/local/rvm/gems/ruby-2.0.0-p648/gems/savon-2.11.2/lib/savon/response.rb:85:in `raise_soap_and_http_errors!'
  </code></pre>
  
  <p>what is this error indicating? how can I debug it?</p>
  
  <p><strong>UPDATE:</strong>
  There was an issue when initializing the Savon client, the documentation said I need to send a Base43 encoded "username": "password" like i did previously but just sending the username &amp; password as below worked fine.</p>
  
  <pre><code>def client
    client = Savon.client(
        wsdl: END_POINT,
        basic_auth: ["username", "password"],
        log: true,
        pretty_print_xml: true
      )
    client.call(:invia_movimentazione, message: message, soap_action: '')
  end
  </code></pre>