调用包含元素具有不同名称空间的Web服务时出现肥皂请求问题

问题描述

我停留在要调用Web服务的位置,它返回<Element {urn:com.workday/tenants/iadmin_dpt2/data/custom}covid19 at 0x2445a9a3600>之类的对象,而不是正确的xml

SOAPUI中的肥皂请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:cus="urn:com.workday/tenants/super/data/custom" xmlns:bsvc="urn:com.workday/bsvc">
   <soapenv:Header/>
   <soapenv:Body>
      <bsvc:Edit_Worker_Additional_Data_Request bsvc:version="v34.0">
         <bsvc:Business_Process_Parameters>
            <bsvc:Auto_Complete>true</bsvc:Auto_Complete>
            <bsvc:Run_Now>true</bsvc:Run_Now>
         </bsvc:Business_Process_Parameters>
         <bsvc:Worker_Custom_Object_Data>
            <bsvc:Effective_Date>2020-07-18Z</bsvc:Effective_Date>
            <bsvc:Worker_Reference>
               <bsvc:ID bsvc:type="Employee_ID">21008</bsvc:ID>
            </bsvc:Worker_Reference>
            <bsvc:Business_Object_Additional_Data>
               <cus:covid19>
                  <cus:covid19AndOthers>
                     <cus:ID cus:type="Extendedalias">high_temperature</cus:ID>
                  </cus:covid19AndOthers>
               </cus:covid19>
               <cus:covid19>
                  <cus:medicalEquipment001>100</cus:medicalEquipment001>
               </cus:covid19>
            </bsvc:Business_Object_Additional_Data>
         </bsvc:Worker_Custom_Object_Data>
      </bsvc:Edit_Worker_Additional_Data_Request>
   </soapenv:Body>
</soapenv:Envelope>

SOAPUI中的肥皂响应

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Body>
      <wd:Edit_Worker_Additional_Data_Response wd:version="v34.0" xmlns:wd="urn:com.workday/bsvc">
         <wd:Event_Reference wd:Descriptor="Edit Worker Additional Data Event: Betty Liu - Director,Payroll Operations on 07/18/2020">
            <wd:ID wd:type="WID">d1f6b86da41201d890ad2ac08f212152</wd:ID>
         </wd:Event_Reference>
         <wd:Worker_Reference wd:Descriptor="Betty Liu">
            <wd:ID wd:type="WID">3bcc416214054db6911612ef25d51e9f</wd:ID>
            <wd:ID wd:type="Employee_ID">21008</wd:ID>
         </wd:Worker_Reference>
         <wd:Effective_Date>2020-07-18</wd:Effective_Date>
         <wd:Additional_Data>
            <custom:covid19 wd:Descriptor="High Temperature" xmlns:custom="urn:com.workday/tenants/super/data/custom">
               <custom:covid19Reference>
                  <custom:ID custom:type="WID">475104cdad4230218fc02af0b0ad008d</custom:ID>
               </custom:covid19Reference>
               <custom:covid19AndOthers wd:Descriptor="High Temperature">
                  <custom:ID custom:type="WID">a5516603346a01c887e555df7a0a2058</custom:ID>
                  <custom:ID custom:type="Custom_List__Value_Alias" custom:parent_type="Custom_List_Web_Service_Alias" custom:parent_id="xyzHealthConditions">high_temperature</custom:ID>
               </custom:covid19AndOthers>
            </custom:covid19>
            <custom:covid19 wd:Descriptor="" xmlns:custom="urn:com.workday/tenants/super/data/custom">
               <custom:covid19Reference>
                  <custom:ID custom:type="WID">475104cdad4230218fc02aee9c4b008c</custom:ID>
               </custom:covid19Reference>
               <custom:medicalEquipment001>100</custom:medicalEquipment001>
            </custom:covid19>
         </wd:Additional_Data>
      </wd:Edit_Worker_Additional_Data_Response>
   </env:Body>
</env:Envelope>

现在,当我想在python中使用zeep实现相同的功能时,我遇到了问题。下面的详细信息

**在python中的请求”

client = Client(credentials['url'],Usernametoken(credentials['username'],credentials['password']))
header = xsd.Element(
    '{urn:com.workday/bsvc}Workday_Common_Header',xsd.ComplexType([
        xsd.Element(
            '{urn:com.workday/bsvc}Include_Reference_Descriptors_In_Response',xsd.Boolean()),])
)
workday_common_header = header(Include_Reference_Descriptors_In_Response=True)

result = client.service.Edit_Worker_Additional_Data(_soapheaders=[workday_common_header],Business_Process_Parameters={
                                                        "Auto_Complete": True,"Run_Now": True
                                                    },Worker_Custom_Object_Data={
                                                        "Effective_Date": "2020-07-18Z","Worker_Reference": {
                                                            "ID":
                                                                {
                                                                    "type": "Employee_ID","_value_1": "21008"
                                                                }
                                                        },"Business_Object_Additional_Data":
                                                            {
                                                                "covid19": [
                                                                    {
                                                                        "covid19AndOthers": {
                                                                            "ID":
                                                                                {
                                                                                    "type": "Extendedalias","_value_1": "high_temperature"
                                                                                }

                                                                        }},{
                                                                        "medicalEquipment001": 100
                                                                    }]
                                                            }
                                                    }

                                                    )

回复

{
    'Event_Reference': {
        'ID': [
            {
                '_value_1': 'd1f6b86da412016eff106b289521e652','type': 'WID'
            }
        ],'Descriptor': 'Edit Worker Additional Data Event: Betty Liu - Director,Payroll Operations on 07/18/2020'
    },'Worker_Reference': {
        'ID': [
            {
                '_value_1': '3bcc416214054db6911612ef25d51e9f','type': 'WID'
            },{
                '_value_1': '21008','type': 'Employee_ID'
            }
        ],'Descriptor': 'Betty Liu'
    },'Effective_Date': datetime.date(2020,7,18),'Additional_Data': [
        [
            <Element {urn:com.workday/tenants/super/data/custom}covid19 at 0x2445a9a3600>,<Element {urn:com.workday/tenants/super/data/custom}covid19 at 0x2445a9a35c0>
        ]
    ],'version': 'v34.0'
}

Additional_Data 响应中的

<Element {urn:com.workday/tenants/super/data/custom}covid19 at 0x2445a9a3600>
代替

 <custom:covid19 wd:Descriptor="High Temperature" xmlns:custom="urn:com.workday/tenants/super/data/custom">
               <custom:covid19Reference>
                  <custom:ID custom:type="WID">475104cdad4230218fc02af0b0ad008d</custom:ID>
               </custom:covid19Reference>
               <custom:covid19AndOthers wd:Descriptor="High Temperature">
                  <custom:ID custom:type="WID">a5516603346a01c887e555df7a0a2058</custom:ID>
                  <custom:ID custom:type="Custom_List__Value_Alias" custom:parent_type="Custom_List_Web_Service_Alias" custom:parent_id="xyzHealthConditions">high_temperature</custom:ID>
               </custom:covid19AndOthers>
            </custom:covid19>

有关网络服务的信息,请参见here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)