You need to sign in to do that
Don't have an account?
security stub class in Apex class for Webservice by parsing WSDL
Salesforce not supported creating class for generating security stub by parsing WSDL file which has security header.
I found a class to generate same:
My WSDL has below security header:
--------------------------------------------------------
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<Username>username123</Username>
<Password>password123</Password>
<Nonce>test123</Nonce>
<wsu:Created>2011-02-25T12:23:39Z</wsu:Created>
</UsernameToken>
</Security>
Class to generate same :
-------------------------------------
Add below sub class:
public class Security_element{
public Security_element(String username, String password. String Nonce, String created) {
usernameToken = new UsernameToken_element(username,password, created);
}
public UsernameToken_element usernameToken;
private String[] usernameToken_type_info = new String[] {'UsernameToken','http://www.w3.org/2001/XMLSchema','element','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
private String[] field_order_type_info = new String[]{'usernameToken'};
}
public class UsernameToken_element {
public UsernameToken_element(String username, String password, String Nonce, String Created) {
this.username = username;
this.password = password;
this.nonce= Nonce;
this.created = '2011-02-25T12:23:39Z';
this.wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
}
public String username;
public String password;
public String nonce;
public String created;
public String wsu;
private String[] wsu_att_info = new String[] {'xmlns:wsu'};
private String[] username_type_info = new String[]{'Username','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
private String[] password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','element','1','1','false'};
private String[] created_type_info = new String[]{'wsu:Created','http://www.w3.org/2001/XMLSchema','element','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
private String[] field_order_type_info = new String[]{'username','password','Nonce','created'};
}
I am not tested above code, please make sure this code generated correct request with security header.
Regards,
Anoop