PowerBuilder
PowerBuilder
Another SOAP with MTOM XOP Attachment Example
See more HTTP Examples
Demonstrates another multipart/related MTOM SOAP request that adds additional headers in each MIME sub-part, and also specifies Content-Transfer-Encoding in the sub-parts.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Req
string ls_XmlBody
string ls_XmlBody2
integer li_UseTls
oleobject loo_Resp
oleobject loo_XmlResponse
li_Success = 0
// This example sends a request such as the following:
// POST /FseInsServicesWeb/services/fseComunicazioneMetadati HTTP/1.1
// Connection: Keep-Alive
// Content-Length: 50649
// Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"; boundary="----=_Part_0_355796458.1662133302632"
// Accept-Encoding: gzip,deflate
// Authorization: Basic xxxxx
// Host: ...
// SOAPAction: "http://comunicazionemetadati.wsdl.fse.ini.finanze.it/ComunicazioneMetadati"
// MIME-Version: 1.0
//
// ------=_Part_0_355796458.1662133302632
// Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
// Content-Transfer-Encoding: 8bit
// Content-ID: <rootpart@soapui.org>
//
// <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://comunicazionemetadatirichiesta.xsd.fse.ini.finanze.it" xmlns:tip="http://tipodaticomunicazionemetadati.xsd.fse.ini.finanze.it">
// <soapenv:Header/>
// ...
//
// ------=_Part_0_355796458.1662133302632
// Content-Type: text/xml; charset=Cp1252
// Content-Transfer-Encoding: quoted-printable
// Content-ID: <CDA2LAB_190_signed.xml>
// Content-Disposition: attachment; name="CDA2LAB_190_signed.xml"
//
// <!-- INSERIRE IL RIFERIMENTO AL FOGLIO DI STILE DI AGID OPPURE INSERIRNE UN=
// ...
//
// ------=_Part_0_355796458.1662133302632--
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.HttpVerb = "POST"
loo_Req.Path = "/FseInsServicesWeb/services/fseComunicazioneMetadati"
// Chilkat will automatically generate and add a boundary string.
loo_Req.ContentType = "multipart/related; type=~"application/xop+xml~"; start=~"<rootpart@soapui.org>~"; start-info=~"text/xml~""
loo_Req.AddHeader("SOAPAction","some-SOAP-action")
loo_Req.AddHeader("Connection","Keep-Alive")
loo_Req.AddHeader("Accept-Encoding","gzip,deflate")
loo_Req.AddHeader("MIME-Version","1.0")
// Chilkat will automatically add the Content-Length and Host headers.
// The "Authorization: Basic ..." header is added by setting the Login and Password and specifying Basic authentication:
loo_Http.Login = "..."
loo_Http.Password = "..."
loo_Http.BasicAuth = 1
// Add the 1st multipart/related sub-part, which is the SOAP envelope.
ls_XmlBody = "<soapenv:Envelope ...."
li_Success = loo_Req.AddStringForUpload2("","",ls_XmlBody,"utf-8","application/xop+xml; type=~"text/xml~"; charset=utf-8")
// Additional headers for the 1st sub-part
li_Success = loo_Req.AddSubHeader(0,"Content-ID","<rootpart@soapui.org>")
li_Success = loo_Req.AddSubHeader(0,"Content-Transfer-Encoding","8bit")
li_Success = loo_Req.AddSubHeader(0,"Content-Disposition","")
// Add the 2nd multipart/related sub-part, which is the signed XML
ls_XmlBody2 = "<!-- INSERIRE IL RIFERIMENT ...."
li_Success = loo_Req.AddStringForUpload2("CDA2LAB_190_signed.xml","",ls_XmlBody2,"Cp1252","text/xml; charset=Cp1252")
// Additional headers for the 2nd sub-part.
li_Success = loo_Req.AddSubHeader(1,"Content-ID","<CDA2LAB_190_signed.xml>")
li_Success = loo_Req.AddSubHeader(1,"Content-Transfer-Encoding","quoted-printable")
li_Success = loo_Req.AddSubHeader(1,"Content-Disposition","attachment; name=~"CDA2LAB_190_signed.xml~"")
loo_Http.FollowRedirects = 1
li_UseTls = 1
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpSReq("fseservicetest.sanita.finanze.it",443,li_UseTls,loo_Req,loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
destroy loo_Resp
return
end if
loo_XmlResponse = create oleobject
li_rc = loo_XmlResponse.ConnectToNewObject("Chilkat.Xml")
li_Success = loo_XmlResponse.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_XmlResponse.GetXml()
destroy loo_Http
destroy loo_Req
destroy loo_Resp
destroy loo_XmlResponse