login about faq

I have to send a POST request to a webservice with an XML Soap and a zip file attachment.
The result should be

POST /InvioTelematicoSS730pMtomWeb/InvioTelematicoSS730pMtomPort HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: multipart/related; type="text/xml"; start="<rootpart@soapui.org>";boundary="----=_Part_3_640244516.1446475016664"
    SOAPAction: ""
    Authorization: Basic VVpWUzZCV1M6UFhOREVLNlA=
    MIME-Version: 1.0
    Content-Length: 8036
    Host: invioSS730pTest.sanita.finanze.it
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    ------=_Part_3_640244516.1446475016664"

    Content-Type: text/xml; charset=UTF-8"
    Content-Transfer-Encoding: 8bit"
    Content-ID: <rootpart@soapui.org>"

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ejb="http://ejb.invioTelematicoSS730p.sanita.finanze.it/">
       <soapenv:Header/>
       <soapenv:Body>
          <ejb:inviaFileMtom>
             <nomeFileAllegato>20141201-20141210_20151027182804.ZIP</nomeFileAllegato>
             <pincodeInvianteCifrato>XXXXXXXXXXXXXXX</pincodeInvianteCifrato>
             <datiProprietario>
                <codiceRegione>000</codiceRegione>
                <codiceAsl>000</codiceAsl>
                <codiceSSA>88888888</codiceSSA>
                <cfProprietario>PROVAX00X00X000Y</cfProprietario>
             </datiProprietario>
             <documento/>
          </ejb:inviaFileMtom>
       </soapenv:Body>
    </soapenv:Envelope>"

    ------=_Part_3_640244516.1446475016664"

    Content-Type: application/octet-stream"
    Content-Transfer-Encoding: binary"
    Content-ID: <20141201-20141210_20151027182804.ZIP>"
    Content-Disposition: attachment; name="20141201-20141210_20151027182804.ZIP""

    [file_content]
    ------=_Part_3_640244516.1446475016664--"

I've tried by creating an HttpRequest and after sets the header fields, i've used the LoadBodyFromString to load the XML object and the FILETOSTR of the zip, but it doesn't use the boundary so the result is not accepted. So i've tried by creating a MIME object, adding the xml and the file as parts (AppendParts); this return a MIME object with its own header and boundary, but i don't know how to load it in the HttpRequest object. Can someone help me?

asked Nov 02 '15 at 11:57

b_mat_ita's gravatar image

b_mat_ita
1112


123next page »

Solved! Even if i still have problems with the attachment's data, so i'm going to open another question about it.

Btw, for those who want to know how i've handle it, here you are:
. first i've created the soap object with the XML object ;
. then i've created a MIME object and added the soap object and the attachment file with the AppendPart() method and saving the boundary value;
. so i've created the HttpRequest object, where i've set the Header fields ( Host, SoapAction, Boundary etc ) and composed the body by passing the MIME body only ( using the GetEntireBody() method ) as parameter for the LoadBodyFromString() of the HttpRequest object;
. lastly, i've invocked the SynchronousRequest() method of the Http object

It is certainly not the best way to do it, but it works for me so i hope it could be usefull for someone.

link

answered Nov 05 '15 at 08:40

b_mat_ita's gravatar image

b_mat_ita
1112

If you have MIME, you could try to get XML string by using method GetXml() of MIME object and then pass this XML string into the method PostXml() of Http object.

link

answered Nov 03 '15 at 10:39

Zongot's gravatar image

Zongot
1

Thanks for the answer, it could be a solution but:
- webservice require several fields in header like authorization, host etc... does the PostXml() handle them?
- how to upload an attachment ( second MIME in example ) with PostXml / Http object?

Thanks

link

answered Nov 03 '15 at 11:07

b_mat_ita's gravatar image

b_mat_ita
1112

To answer your second question - if I understood correctly, you've already created MIME object containing zip file. The method GetXml() returns entire XML, including zip – so, you don't have to worry about attachment.

To answer your first question – if header has additional options, when the PostXml() is not suitable, because it supports only web address as an endpoint. Instead, you have to create synchronous HttpRequest, set its parameters and call the method request.LoadBodyFromString(xmlStr,"utf-8"), where xmlStr is your string, retrieved earlier by GetXml(). After that, you can get response = http.SynchronousRequest(..., request) There is example, available at: http://www.example-code.com/csharp/http_xmlHttpRequestVerbs.asp

link

answered Nov 03 '15 at 12:45

Zongot's gravatar image

Zongot
1

Yes its true, i've created a MIME object with 2 "sub-parts", MIME themselves: the Soap XML part and the binary file data part, so this object has his own Head ( Content-Type: multipart/mixed; boundary=... ) and two boundary parts.
But if i use LoadBodyFromString method in the HttpRequest object, this add the whole MIME object as body, and the webserver refuse it.

Same problem with the Http.PostXML( MIME.GetXML() ): the GetXML return an object that the webserver doesn't accept.

Instead, i tried to use the Http object by setting the header fields and using the PostXML method with the pure xml object, with the binary data of the zip encoded in base64 inside the xml tag: the server accepted it!
So the problem is the MTOM technology, but i need to find the way to attach the binary data of the file to the Http object with MTOM correctly because now is advice by the webserver, but sooner will be required.

link

answered Nov 04 '15 at 06:03

b_mat_ita's gravatar image

b_mat_ita
1112

Many thanks for sharing your work. I am in the same situation: I need MTOM.

link

answered Nov 17 '15 at 04:00

diegodec's gravatar image

diegodec
1

Hi b_mat_ita, I have the same problem (730), have you found a solution ? If I understood: - now you are able to send base64 zip file that follow the soap - but using b64 encoding and not the mtom...

it is correct ? Ciao daniele

link

answered Dec 22 '15 at 06:21

Daniele_RomeIT's gravatar image

Daniele_RomeIT
1

Hi Daniele,
yes i've solved it, you can find the solution at the top of this discussion; i used the mtom technology with binary encoding, writing the zip file with b64 enconding within the soap it could work for a while but they have declared that soon will be accepted only the mtom technology.

Hope to be helpful. Ciao

link

answered Dec 22 '15 at 09:20

b_mat_ita's gravatar image

b_mat_ita
1112

Hi everybody, Thank you "Chilkat" ! I will buy the new release asap it will be ready to buy.

When my testing script will works fine I will publish it here in this forum topic. So everybody need to send data to Italy MEF for 730 healtcare invoice collection... will have a trace...

Merry Christmas and Happy New Year daniele

link

answered Dec 23 '15 at 06:31

Daniele_RomeIT's gravatar image

Daniele_RomeIT
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22
×11

Asked: Nov 02 '15 at 11:57

Seen: 2,770 times

Last updated: Jan 18 at 08:27

powered by OSQA