Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. --MIMEBoundary_199ca6b7114b9acca5deb2047d25d5841d4afb7f68281379
  2. Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
  3. Content-Transfer-Encoding: binary
  4. Content-ID: <0.099ca6b7114b9acca5deb2047d25d5841d4afb7f68281379@apache.org>
  5.  
  6. <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><StateHeader xmlns="http://www.statemef.com/StateGatewayService"><MessageID>12345201704200009962</MessageID><RelatesTo>12345201704200009962</RelatesTo><Action>GetNewAcks</Action><Timestamp>2017-02-11T01:54:51.676-05:00</Timestamp><TestIndicator>T</TestIndicator></StateHeader></soapenv:Header><soapenv:Body><GetNewAcksResponse xmlns="http://www.statemef.com/StateGatewayService"><MoreAvailable>true</MoreAvailable><AcknowledgementListAttachmentMTOM><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:299ca6b7114b9acca5deb2047d25d5841d4afb7f68281379@apache.org"></xop:Include></AcknowledgementListAttachmentMTOM></GetNewAcksResponse></soapenv:Body></soapenv:Envelope>
  7. --MIMEBoundary_199ca6b7114b9acca5deb2047d25d5841d4afb7f68281379
  8. Content-Type: application/octet-stream
  9. Content-Transfer-Encoding: binary
  10. Content-ID: <299ca6b7114b9acca5deb2047d25d5841d4afb7f68281379@apache.org>
  11.  
  12. public static MimeEntity Load (ParserOptions options, ContentType contentType, Stream content, CancellationToken cancellationToken = default (CancellationToken));
  13.  
  14. public static MimeEntity Load (ContentType contentType, Stream content, CancellationToken cancellationToken = default (CancellationToken));
  15.  
  16. MimeEntity ParseMultipartFormData (HttpWebResponse response)
  17. {
  18. var contentType = ContentType.Parse (response.ContentType);
  19.  
  20. return MimeEntity.Parse (contentType, response.GetResponseStream ());
  21. }
  22.  
  23. int i = 1;
  24. foreach (var attachment in multipart.OfType<MimePart> ()) {
  25. string fileName = string.Format ("attachment.{0}.dat", i++);
  26. using (var stream = File.Create (fileName))
  27. attachment.ContentObject.DecodeTo (stream);
  28. }
  29.  
  30. HttpWebRequest request = CreateWebRequestGetAcks();
  31. CookieContainer myContainer = new CookieContainer();
  32. request.PreAuthenticate = true;
  33. request.CookieContainer = myContainer;
  34. String username = user;
  35. String password = pwd;
  36. String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
  37. request.Credentials = CredentialCache.DefaultCredentials;
  38. request.Headers.Add("Authorization", " Basic " + encoded);
  39. using (Stream stream = request.GetRequestStream())
  40. {
  41. soapEnvelopeXml.Save(stream);
  42. }
  43. using (WebResponse response = request.GetResponse())
  44. {
  45. using (StreamReader rd = new StreamReader(response.GetResponseStream()))
  46. {
  47. string _soapResult = rd.ReadToEnd();
  48. }
  49. }
  50. public static HttpWebRequest CreateWebRequestGetAcks()
  51. {
  52. HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://xxxxxxxxxx");
  53. webRequest.Headers.Add(@"SOAP:Action");
  54. webRequest.ContentType = "text/xml;charset="utf-8"";
  55. webRequest.Host = "some thing";
  56. webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.34209)";
  57. webRequest.Method = "POST";`
  58. return webRequest;
  59.  
  60.  
  61. }
  62.  
  63. MIME-Version: 1.0 content-type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="MIMEBoundary_someuniqueID";start-info="text/xml"
  64. Server: Microsoft-IIS/10.0
  65. X-Powered-By: ASP.NET
  66. Content-Length:24371900
  67.  
  68.  
  69. --MIMEBoundary_someuniqueID
  70. Content-Type: application/xop+xml; charset=utf-8; type="text/xml" Content-Transfer-Encoding: binary
  71. Content-ID: <http://tempuri.org/0>
  72.  
  73. <soap:Envelope>
  74. <someWrapperElt>
  75. <xop:Include href="cid:uri_of_content"></xop:Include>
  76. </someWrapperElt>
  77. </soap:Envelope>
  78. --MIMEBoundary_someuniqueID
  79. Content-Type: application/octet-stream
  80. Content-Transfer-Encoding: binary
  81. Content-ID: <uri_of_content>
  82.  
  83. ...start.b1n@ry-content-here-etc.fckZ8990832d...
  84. --MIMEBoundary_someuniqueID
  85.  
  86. XmlDictionaryReader mtomReader = XmlDictionaryReader.CreateMtomReader(ms, Encoding.UTF8, XmlDictionaryReaderQuotas.Max);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement