You need to sign in to do that
Don't have an account?
Emma Bindi
SOAP header requires a String however Apex class is a complex type
When parsing WSDL file into Apex we needed to change the header item (user/password) into complex type for Salesforce to accept it.
Now unfortunately, the Apex class is sending the complex type information whereas the external system is expecting a string only.
Ie, External System format requires:
This is what WSDL2Apex generated:
Does anyone have any ideas how I can instead send through just a string for each header item rather than all the extra details?
Now unfortunately, the Apex class is sending the complex type information whereas the external system is expecting a string only.
Ie, External System format requires:
<soapenv:Header> <web:SessionType>none</web:SessionType> <web:PasswordText>topsecret</web:PasswordText> <web:UsernameToken>BROKER</web:UsernameToken> </soapenv:Header>However Salesforce is sending:
<env:Header> <PasswordText xmlns="http://siebel.com/webservices"> <inputParam>topsecret</inputParam> </PasswordText> <SessionType xmlns="http://siebel.com/webservices"> <inputParam>none</inputParam> </SessionType> <UsernameToken xmlns="http://siebel.com/webservices"> <inputParam>BROKER</inputParam> </UsernameToken> </env:Header>
This is what WSDL2Apex generated:
//Generated by wsdl2apex public class AFGFlexWebservices { public class SessionType_element { public String inputParam; private String[] inputParam_type_info = new String[]{'inputParam','http://siebel.com/webservices',null,'1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://siebel.com/webservices','true','false'}; private String[] field_order_type_info = new String[]{'inputParam'}; } public class PasswordText_element { public String inputParam; private String[] inputParam_type_info = new String[]{'inputParam','http://siebel.com/webservices',null,'1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://siebel.com/webservices','true','false'}; private String[] field_order_type_info = new String[]{'inputParam'}; } public class UsernameToken_element { public String inputParam; private String[] inputParam_type_info = new String[]{'inputParam','http://siebel.com/webservices',null,'1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://siebel.com/webservices','true','false'}; private String[] field_order_type_info = new String[]{'inputParam'}; } }
Does anyone have any ideas how I can instead send through just a string for each header item rather than all the extra details?
For those who encounter same issue, we went with the Plan B using a REST post callout with manually created XML request body to resolve this. (only had a couple fields to send/receive from external system)
Tips, SOAPaction was required in the headers along with text/xml content type. Then parsed response with Document & XML classes
All Answers
This will help to identify your query.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thank you, this thread was helpful and I found some interesting reading. Unfortunately the particular situation is in reverse, and I need to output simple type but it is currently complex.
I am considering it may be necessary to manually create the XML and use REST instead?
For those who encounter same issue, we went with the Plan B using a REST post callout with manually created XML request body to resolve this. (only had a couple fields to send/receive from external system)
Tips, SOAPaction was required in the headers along with text/xml content type. Then parsed response with Document & XML classes