Reputation: 100
I am using SOAP package to make a request to workday-api by xml.
Issue is with xml generated by soap package.
generated 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>[email protected]</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>
I need xml is like below
<?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>[email protected]</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>
In soap generated xml contain extra namesapace in soapenv:envelope. How to remove it. And I am getting extra tag after soapenv:body tag.
I am passing below details for header & body.
header:
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>`
and body:
let xml = `<bsvc:Get_Applicants_Request bsvc:version="v32.1">
<bsvc:Request_Criteria>
<bsvc:Email_Address>[email protected]</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>`
and used below method to request xml using soap as workday provides soap api.
let client = await soap.createClientAsync(url, wsdlOptions)
client.addSoapHeader(soapHeader)
let resp = await client.Get_ApplicantsAsync(xml)
Please help me to make xml as I needed using SOAP package.
Upvotes: 2
Views: 700
Reputation: 162
The code sample you provide doesn't show what you are providing as the method arguments (what is the xml object in your code?).
Based on the post I'm assuming that you are building the xml string yourself and want to pass it directly to the SOAP package. In that case, your method argument should look like ("Example with XML String for the args" in the package docs)
const resp = await client.Get_ApplicantsAsync({_xml: xmlBody})
Keep in mind, that you are missing the bsvc
namespace.
You can add it directly in your xml body to the Get_Applicants_Request
element:
<bsvc:Get_Applicants_Request xmlns:bsvc="urn:com.workday/bsvc" bsvc:version="v32.1">
</bsvc:Get_Applicants_Request>
or you can include it in the envelope (perhaps you have other calls that also need this namespace):
client.wsdl.xmlnsInEnvelope += 'xmlns:bsvc="urn:com.workday/bsvc';
Upvotes: 1