multipart SOAP запрос в Савоне - PullRequest
1 голос
/ 28 января 2020

Мне нужно создать этот многочастный запрос в SAVON для вызова executeProcess метода SOAP службы:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsim="http://www.contoso.com/wsimport">
   <soapenv:Header/>
   <soapenv:Body>
      <wsim:executeProcess>
         <wsim:common-attribute wsim:name="client-id" wsim:value="CLIENT1"/>
         <wsim:common-attribute wsim:name="process-id" wsim:value="WSSync"/>
         <wsim:document wsim:name="Test.pdf" wsim:content-type="application/pdf">
            <!--Part name of multipart content-->
            <wsim:content>cid:1546150551033</wsim:content>
            <wsim:attribute wsim:name="type-id" wsim:value="fatp_el" />
            <wsim:attribute wsim:name="document-date" wsim:value="20200120"/>
            <wsim:custom-attribute wsim:name="year" wsim:value="2020"/>
            <wsim:custom-attribute wsim:name="month" wsim:value="01"/>
            <wsim:custom-attribute wsim:name="day" wsim:value="20"/>
         </wsim:document>
      </wsim:executeProcess>
   </soapenv:Body>
</soapenv:Envelope>

Как я могу загрузить файл и сослаться на тег? Могу ли я использовать savon-multipart драгоценный камень?

Как я могу объявить теги common-attribute, document, attribute и custom-attribute?

Я пробовал этот код без успеха, я довольно запутался ...

client = Savon.client wsdl: wsdl, basic_auth: ["user", "password"]
message = {}
message["common-attribute"] = []
common_attribute = {"common-attribute": "", attributes!: {"common-attribute": {name: "client-id", "value": "CLIENT1"}}}
message["common-attribute"] << common_attribute
common_attribute = {"common-attribute": "", attributes!: {"common-attribute": {name: "process-id", "value": "WSSync"}}}
message["common-attribute"] << common_attribute
...
response = client.build_request :execute_process, message: message
puts response.body
...