title: macOS swift: connecting to German "internetmarke" via SOAP
body: <p>Here is my solution for connecting to the German online stamp serivce &quot;Internetmarke&quot; via SOAP for those who need to do the same (sometimes)</p>
  <pre class="lang-swift prettyprint-override"><code>    private func stampLogIn() {
          let aktDate = dateFormatterSOAP.string(from: Date())
          
          let partnerID: String = &quot;XXXXX&quot;
          let partnerKey: String = &quot;sajklfgweiqulskdjfvbluw&quot;
          
          let sign: String = partnerID + &quot;::&quot; + aktDate + &quot;::1::&quot; + partnerKey
          
          let signature_key = Insecure.MD5.hash(data: sign.data(using: .utf8)!).map {String(format: &quot;%02x&quot;, $0)}.joined()
  
          let message: String = &quot;&quot;&quot;
  &lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:v3=&quot;http://oneclickforapp.dpag.de/V3&quot;&gt;
   &lt;soapenv:Header&gt;
    &lt;v3:PARTNER_ID&gt;\(partnerID)&lt;/v3:PARTNER_ID&gt;
    &lt;v3:REQUEST_TIMESTAMP&gt;\(aktDate)&lt;/v3:REQUEST_TIMESTAMP&gt;
    &lt;v3:KEY_PHASE&gt;1&lt;/v3:KEY_PHASE&gt;
    &lt;v3:PARTNER_SIGNATURE&gt;\(signature_key.prefix(8))&lt;/v3:PARTNER_SIGNATURE&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
    &lt;v3:AuthenticateUserRequest&gt;
     &lt;v3:username&gt;login_mail@dhldp-test.de&lt;/v3:username&gt;
     &lt;v3:password&gt;myPassword&lt;/v3:password&gt;
    &lt;/v3:AuthenticateUserRequest&gt;
   &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  &quot;&quot;&quot;
          let urlString = &quot;https://internetmarke.deutschepost.de/OneClickForAppV3?wsdl&quot;
          let url = URL(string: urlString)!
          let request = NSMutableURLRequest(url: url)
          request.httpMethod = &quot;POST&quot;
          request.addValue(&quot;text/xml; charset=utf-8&quot;, forHTTPHeaderField: &quot;Content-Type&quot;)
          request.addValue(&quot;\(message.count)&quot;, forHTTPHeaderField: &quot;Content-Length&quot;)
          request.httpBody = message.data(using: .utf8)
          
          let task = URLSession.shared
              .dataTask(with: request as URLRequest,
                        completionHandler: { data, response, error in
                  guard error == nil else {
                      // Handle the error
                      print(error!)
                      return
                  }
                  guard let data = data else {
                      return
                  }
                  // Continue checking response or data...
                  let dataStr = String(decoding: data, as: UTF8.self)
                  // Here goes XML-Parsing
                  print(dataStr)
              })
          task.resume()
      }
  </code></pre>
  <p>This ist only for the first step. Of course the other steps have to be done analogically. To be done: the XML parsing of the response.</p>