将数据框转换为使用自定义SOAP封套的有效载荷?

huangapple go评论70阅读模式
英文:

Convert dataframe into a payload using custom-made SOAP-Envelope?

问题

我需要帮助使用我拥有的数据框架来构建 SOAP Envelope,以便将其用作POST API请求的有效载荷(在SAP服务器上)。此有效载荷必须采用特定格式/ SOAP Envelope,我使用WSDL URL接收到了它。

以下是我用于发布数据的代码。

import requests

url = '我的SAP网址';

# 结构化XML
payload = df_xml_test.to_xml()
certificate_file = "certificate.pem"

# 标头
headers = {
    'Content-Type': 'application/soap+xml; charset=utf-8'
}

# 发送POST请求
response = requests.request("POST", url, headers=headers, data=payload,
                            cert=certificate_file, verify=False)
  
# 打印响应
print(response.text)
print(response)

我收到了一个响应 500 而不是响应 200

英文:

I have a Python project where I am supposed to convert my dataframe into a payload for POST API hit (on a SAP server). This payload must be in a particular format/SOAP Envelope which I received using the WSDL URL. I need help in framing the SOAP Envelope using the dataframe that I have.

Below is the code I am using to Post the data.

import requests

url = 'my SAP url'


# structured XML
payload = df_xml_test.to_xml()
certificate_file = "certificate.pem"

# headers
headers = {
    'Content-Type': 'application/soap+xml; charset=utf-8'
}

# POST request
response = requests.request("POST", url, headers=headers, data=payload,
                            cert=certificate_file,verify=False)
  
# prints the response
print(response.text)
print(response)

I received a Response 500 instead of a Response 200.

答案1

得分: 1

使用字符串附加和迭代来实现。

英文:

Did using string append and iterations

huangapple
  • 本文由 发表于 2023年2月23日 19:31:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定