【发布时间】:2019-10-27 17:22:24
【问题描述】:
我正在使用SOAP 包通过xml 向workday-api 发出请求。
问题在于soap包生成的xml。
生成的 XML
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wd-wsdl="urn:com.workday/bsvc/Recruiting"
xmlns:wd="urn:com.workday/bsvc"
xmlns:nyw="urn:com.netyourwork/aod">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>Username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<wd:Get_Applicants_Request
xmlns:wd="urn:com.workday/bsvc"
xmlns="urn:com.workday/bsvc">
<bsvc:Get_Applicants_Request bsvc:version="v32.1">
<bsvc:Request_Criteria>
<bsvc:Email_Address>abc@gmail.com</bsvc:Email_Address>
</bsvc:Request_Criteria>
<bsvc:Response_Group>
<bsvc:Include_Reference>true</bsvc:Include_Reference>
<bsvc:Include_Personal_Information>true</bsvc:Include_Personal_Information>
<bsvc:Include_Recruiting_Information>true</bsvc:Include_Recruiting_Information>
<bsvc:Include_Qualification_Profile>true</bsvc:Include_Qualification_Profile>
<bsvc:Include_Resume>false</bsvc:Include_Resume>
<bsvc:Include_Background_Check>false</bsvc:Include_Background_Check>
<bsvc:Include_External_Integration_ID_Data>false</bsvc:Include_External_Integration_ID_Data>
</bsvc:Response_Group>
</bsvc:Get_Applicants_Request>
</wd:Get_Applicants_Request>
</soapenv:Body>
</soapenv:Envelope>
我需要的xml如下所示
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bsvc="urn:com.workday/bsvc">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>Username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<bsvc:Get_Applicants_Request bsvc:version="v32.1">
<bsvc:Request_Criteria>
<bsvc:Email_Address>abc@gmail.com</bsvc:Email_Address>
</bsvc:Request_Criteria>
<bsvc:Response_Group>
<bsvc:Include_Reference>true</bsvc:Include_Reference>
<bsvc:Include_Personal_Information>true</bsvc:Include_Personal_Information>
<bsvc:Include_Recruiting_Information>true</bsvc:Include_Recruiting_Information>
<bsvc:Include_Qualification_Profile>true</bsvc:Include_Qualification_Profile>
<bsvc:Include_Resume>false</bsvc:Include_Resume>
<bsvc:Include_Background_Check>false</bsvc:Include_Background_Check>
<bsvc:Include_External_Integration_ID_Data>false</bsvc:Include_External_Integration_ID_Data>
</bsvc:Response_Group>
</bsvc:Get_Applicants_Request>
</soapenv:Body>
</soapenv:Envelope>
在soap 生成的xml 中,soapenv:envelope 中包含额外的命名空间。如何删除它。我在 soapenv:body 标签之后得到了额外的标签。
我正在传递以下标题和正文的详细信息。
标题:
let soapHeader = `<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>Username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>`
和身体:
let xml = `<bsvc:Get_Applicants_Request bsvc:version="v32.1">
<bsvc:Request_Criteria>
<bsvc:Email_Address>abc@gmail.com</bsvc:Email_Address>
</bsvc:Request_Criteria>
<bsvc:Response_Group>
<bsvc:Include_Reference>true</bsvc:Include_Reference>
<bsvc:Include_Personal_Information>true</bsvc:Include_Personal_Information>
<bsvc:Include_Recruiting_Information>true</bsvc:Include_Recruiting_Information>
<bsvc:Include_Qualification_Profile>true</bsvc:Include_Qualification_Profile>
<bsvc:Include_Resume>false</bsvc:Include_Resume>
<bsvc:Include_Background_Check>false</bsvc:Include_Background_Check>
<bsvc:Include_External_Integration_ID_Data>false</bsvc:Include_External_Integration_ID_Data>
</bsvc:Response_Group>
</bsvc:Get_Applicants_Request>`
并使用以下方法使用soap请求xml,因为工作日提供soap api。
let client = await soap.createClientAsync(url, wsdlOptions)
client.addSoapHeader(soapHeader)
let resp = await client.Get_ApplicantsAsync(xml)
请帮助我根据需要使用 SOAP 包制作 xml。
【问题讨论】:
-
请看,这是工作日的HR apigithub.com/hikmat30ce/WorkdayIntegrator-HR
标签: node.js xml soap workday-api