function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rachit Kumar JainRachit Kumar Jain 

How to remove name space xmlns from the AddressValidatioRequest Tag in the XML request generated by WSDL class

Please Help. Want to remove Namespace from xml tag-<AddressValidationRequest xmlns="http://fedex.com/ws/addressvalidation/v4">

 
XML-
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <env:Header />
   <env:Body>
      <AddressValidationRequest xmlns="http://fedex.com/ws/addressvalidation/v4">
         <WebAuthenticationDetail>
            <UserCredential>
               <Key>*****</Key>
               <Password>****</Password>
            </UserCredential>
         </WebAuthenticationDetail>
         <ClientDetail>
            <AccountNumber>****</AccountNumber>
            <MeterNumber>****</MeterNumber>
            <Localization>
               <LanguageCode>EN</LanguageCode>
               <LocaleCode>us</LocaleCode>
            </Localization>
         </ClientDetail>
         <TransactionDetail>
            <CustomerTransactionId>AddressValidationRequest</CustomerTransactionId>
            <Localization>
               <LanguageCode>EN</LanguageCode>
               <LocaleCode>us</LocaleCode>
            </Localization>
         </TransactionDetail>
         <Version>
            <ServiceId>aval</ServiceId>
            <Major>4</Major>
            <Intermediate>0</Intermediate>
            <Minor>0</Minor>
         </Version>
         <InEffectAsOfTimestamp>2017-05-10T14:30:03.1982091+05:30</InEffectAsOfTimestamp>
         <AddressesToValidate>
            <ClientReferenceId />
            <Contact>
               <PersonName>*****</PersonName>
               <CompanyName>*****</CompanyName>
               <PhoneNumber>*****</PhoneNumber>
               <EMailAddress>*****</EMailAddress>
            </Contact>
            <Address>
               <StreetLines>*****</StreetLines>
               <City>*****</City>
               <StateOrProvinceCode>CA</StateOrProvinceCode>
               <PostalCode>94608</PostalCode>
               <CountryCode>US</CountryCode>
               <Residential>true</Residential>
            </Address>
         </AddressesToValidate>
      </AddressValidationRequest>
   </env:Body>
</env:Envelope>`

WSDL class generated by salesforce-
 
public class AddressValidationRequest {
        public fedexComWsAddressvalidationV4.WebAuthenticationDetail WebAuthenticationDetail;
        public fedexComWsAddressvalidationV4.ClientDetail ClientDetail;
        public fedexComWsAddressvalidationV4.TransactionDetail TransactionDetail;
        public fedexComWsAddressvalidationV4.VersionId Version;
        public String InEffectAsOfTimestamp;
        public fedexComWsAddressvalidationV4.AddressToValidate[] AddressesToValidate;
        private String[] WebAuthenticationDetail_type_info = new String[]{'WebAuthenticationDetail','http://fedex.com/ws/addressvalidation/v4',null,'1','1','false'};
        private String[] ClientDetail_type_info = new String[]{'ClientDetail','http://fedex.com/ws/addressvalidation/v4',null,'1','1','false'};
        private String[] TransactionDetail_type_info = new String[]{'TransactionDetail','http://fedex.com/ws/addressvalidation/v4',null,'0','1','false'};
        private String[] Version_type_info = new String[]{'Version','http://fedex.com/ws/addressvalidation/v4',null,'1','1','false'};
        private String[] InEffectAsOfTimestamp_type_info = new String[]{'InEffectAsOfTimestamp','http://fedex.com/ws/addressvalidation/v4',null,'0','1','false'};
        private String[] AddressesToValidate_type_info = new String[]{'AddressesToValidate','http://fedex.com/ws/addressvalidation/v4',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://fedex.com/ws/addressvalidation/v4','true','true'};
        private String[] field_order_type_info = new String[]{'WebAuthenticationDetail','ClientDetail','TransactionDetail','Version','InEffectAsOfTimestamp','AddressesToValidate'};
    }

    public class AddressValidationServicePort {
        public String endpoint_x = 'https://wsbeta.fedex.com:443/web-services/addressvalidation';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://fedex.com/ws/addressvalidation/v4', 'fedexComWsAddressvalidationV4'};
        public fedexComWsAddressvalidationV4.AddressValidationReply addressValidation(fedexComWsAddressvalidationV4.WebAuthenticationDetail WebAuthenticationDetail,fedexComWsAddressvalidationV4.ClientDetail ClientDetail,fedexComWsAddressvalidationV4.TransactionDetail TransactionDetail,fedexComWsAddressvalidationV4.VersionId Version,String InEffectAsOfTimestamp,fedexComWsAddressvalidationV4.AddressToValidate[] AddressesToValidate) {
            fedexComWsAddressvalidationV4.AddressValidationRequest request_x = new fedexComWsAddressvalidationV4.AddressValidationRequest();
            request_x.WebAuthenticationDetail = WebAuthenticationDetail;
            request_x.ClientDetail = ClientDetail;
            request_x.TransactionDetail = TransactionDetail;
            request_x.Version = Version;
            request_x.InEffectAsOfTimestamp = InEffectAsOfTimestamp;
            request_x.AddressesToValidate = AddressesToValidate;
            fedexComWsAddressvalidationV4.AddressValidationReply response_x;
            Map<String, fedexComWsAddressvalidationV4.AddressValidationReply> response_map_x = new Map<String, fedexComWsAddressvalidationV4.AddressValidationReply>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://fedex.com/ws/addressvalidation/v4/addressValidation',
              'http://fedex.com/ws/addressvalidation/v4',
              'AddressValidationRequest',
              'http://fedex.com/ws/addressvalidation/v4',
              'AddressValidationReply',
              'fedexComWsAddressvalidationV4.AddressValidationReply'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }

​

 
Best Answer chosen by Rachit Kumar Jain
Arpit BajpaiArpit Bajpai
Hello Rachit,

Have you check your request body properly.
Please recheck it

I have copied your request body and edit it with my test key and password and meter number, and remove the blank spaces between tags, remove empty tags which will lead to null pointer exception. Example: <ClientReferenceId></ClientReferenceId> etc 

Remove it if not required a parameter for the request, or give the desired input as explained in the documentation.
Refer this documentation for help https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201607/FedEx_WebServices_ShipService_WSDLGuide_v2016.pdf

This works for me, hope it helps you.

Please mark it as best answer if it resolved your problem.

Regards,
Arpit
 

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Rachit,

Double check the error you are getting back from the web service.

Having the namespace defined on the AddressValidationRequest element versus the soapenv: Envelope element shouldn't matter. I.e. You can define the default xmlns attribute anywhere. The only consequence is if any other namespace needs to be explicitly set on child elements.

Hope this helps.

Please mark it as solved if it's resolved.

Regards,
Nagendra.
Arpit BajpaiArpit Bajpai
Hello Rachit,

Have you check your request body properly.
Please recheck it

I have copied your request body and edit it with my test key and password and meter number, and remove the blank spaces between tags, remove empty tags which will lead to null pointer exception. Example: <ClientReferenceId></ClientReferenceId> etc 

Remove it if not required a parameter for the request, or give the desired input as explained in the documentation.
Refer this documentation for help https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201607/FedEx_WebServices_ShipService_WSDLGuide_v2016.pdf

This works for me, hope it helps you.

Please mark it as best answer if it resolved your problem.

Regards,
Arpit
 
This was selected as the best answer