1

My mission is the following : integrate a web service (SOAP protocol) into a dev Salesforce org. I discovered the different way to integrate into Salesforce (reading official Salesforce documentation (https://developer.salesforce.com/docs/atlas.en-us.224.0.apexcode.meta/apexcode/apex_dev_guide.htm) + doing several Trailhead course (https://trailhead.salesforce.com/fr/content/learn/modules/apex_integration_services and more) + google search, and for me the corresponding ways to obtain my Apex classes are :

  • Generate new Apex code from WSDL using the WSDL2APEX Salesforce parser (facing commons errors http://www.fishofprey.com/2011/03/consuming-aspnet-web-service-from.html).
  • Write the Apex code from scratch (wish I can't really succeed in).
  • Using FuseIT SFDC Explorer (facing errors when I try to import the Apex classes into Salesforce after generating my classes).

After multiple try to parse WSDL, or to write Apex code, I claim for support .. I tryed to debug my xml file multiple time, nothing worked. I am currently trying to write Apex class methods that can be exposed as custom SOAP Web service calls, using the webservice keyword to define theses method but I have Apex compiler errors due to usage of hand writed Apex classes.. Salesforce seems to not let people use external tools and others method.

What am I doing wrong ? Is there others profesionnal way to do it ? Thanks by advance for the help.

WSDL as below :

<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.3.0 svn-revision#3528ea595bd29309f69172d231bbce272d21035c. -->
<!-- Generated by JAX-WS RI (http://javaee.github.io/metro-jax-ws). RI's version is JAX-WS RI 2.3.0 svn-revision#3528ea595bd29309f69172d231bbce272d21035c. -->
<definitions
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:wsp="http://www.w3.org/ns/ws-policy"
    xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="Test123"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="Test123" name="AddressProcessorService">
    <types>
        <xsd:schema
            xmlns:tns="Test123"
            xmlns="Test123"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" version="1.0" targetNamespace="Test123">
            <xsd:element name="AuthenticationFault" type="AuthenticationException"/>
            <xsd:element name="NotEnougthCreditsFault" type="NotEnoughCreditsException"/>
            <xsd:element name="ServiceFault" type="ServiceException"/>
            <xsd:element name="ValidationFault" type="ValidationException"/>
            <xsd:element name="accounting" nillable="true" type="string"/>
            <xsd:element name="adrIn" nillable="true" type="addressIn"/>
            <xsd:element name="adrOut" nillable="true" type="addressOut"/>
            <xsd:element name="createdDate" nillable="true" type="string"/>
            <xsd:element name="digest" nillable="true" type="string"/>
            <xsd:element name="nonce" nillable="true" type="string"/>
            <xsd:element name="ticket" nillable="true" type="string"/>
            <xsd:element name="user" nillable="true" type="string"/>
            <xsd:complexType name="addressIn">
                <xsd:sequence>
                    <xsd:element name="line1" type="string" minOccurs="0"/>
                    <xsd:element name="line2" type="string" minOccurs="0"/>
                    <xsd:element name="line3" type="string" minOccurs="0"/>
                    <xsd:element name="line4" type="string" minOccurs="0"/>
                    <xsd:element name="locality" type="string" minOccurs="0"/>
                    <xsd:element name="postCode" type="string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="addressOut">
                <xsd:sequence>
                    <xsd:element name="geoCode" type="string" minOccurs="0"/>
                    <xsd:element name="hexacleNameCode" type="string" minOccurs="0"/>
                    <xsd:element name="hexacleNumberCode" type="string" minOccurs="0"/>
                    <xsd:element name="hexaligne3Id" type="string" minOccurs="0"/>
                    <xsd:element name="hexaligne3ReturnCode" type="string" minOccurs="0"/>
                    <xsd:element name="hexaviaNumber" type="string" minOccurs="0"/>
                    <xsd:element name="inseeCode" type="string" minOccurs="0"/>
                    <xsd:element name="line1" type="string" minOccurs="0"/>
                    <xsd:element name="line2" type="string" minOccurs="0"/>
                    <xsd:element name="line3" type="string" minOccurs="0"/>
                    <xsd:element name="line4" type="string" minOccurs="0"/>
                    <xsd:element name="locality" type="string" minOccurs="0"/>
                    <xsd:element name="mainWord" type="string" minOccurs="0"/>
                    <xsd:element name="postCode" type="string" minOccurs="0"/>
                    <xsd:element name="proposals" type="proposal" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
                    <xsd:element name="proposalsCount" type="xsd:int"/>
                    <xsd:element name="returnCode" type="string" minOccurs="0"/>
                    <xsd:element name="returnText" type="string" minOccurs="0"/>
                    <xsd:element name="roudisNumber" type="string" minOccurs="0"/>
                    <xsd:element name="streetBis" type="string" minOccurs="0"/>
                    <xsd:element name="streetName" type="string" minOccurs="0"/>
                    <xsd:element name="streetNumber" type="string" minOccurs="0"/>
                    <xsd:element name="streetType" type="string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="proposal">
                <xsd:sequence>
                    <xsd:element name="locality" type="string" minOccurs="0"/>
                    <xsd:element name="maxEvenBoundary" type="string" minOccurs="0"/>
                    <xsd:element name="maxOddBoundary" type="string" minOccurs="0"/>
                    <xsd:element name="minEvenBoundary" type="string" minOccurs="0"/>
                    <xsd:element name="minOddBoundary" type="string" minOccurs="0"/>
                    <xsd:element name="postCode" type="string" minOccurs="0"/>
                    <xsd:element name="street" type="string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="NotEnoughCreditsException">
                <xsd:sequence>
                    <xsd:element name="code" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="errorMessage" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="message" type="string" form="unqualified" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="AuthenticationException">
                <xsd:sequence>
                    <xsd:element name="code" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="errorMessage" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="message" type="string" form="unqualified" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ValidationException">
                <xsd:sequence>
                    <xsd:element name="code" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="errorMessage" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="message" type="string" form="unqualified" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ServiceException">
                <xsd:sequence>
                    <xsd:element name="code" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="errorMessage" type="string" form="unqualified" minOccurs="0"/>
                    <xsd:element name="message" type="string" form="unqualified" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name="processAddress">
        <part name="adrIn" element="tns:adrIn"/>
        <part name="user" element="tns:user"/>
        <part name="digest" element="tns:digest"/>
        <part name="nonce" element="tns:nonce"/>
        <part name="createdDate" element="tns:createdDate"/>
        <part name="ticket" element="tns:ticket"/>
        <part name="accounting" element="tns:accounting"/>
    </message>
    <message name="processAddressResponse">
        <part name="adrOut" element="tns:adrOut"/>
    </message>
    <message name="NotEnoughCreditsException">
        <part name="fault" element="tns:NotEnougthCreditsFault"/>
    </message>
    <message name="AuthenticationException">
        <part name="fault" element="tns:AuthenticationFault"/>
    </message>
    <message name="ValidationException">
        <part name="fault" element="tns:ValidationFault"/>
    </message>
    <message name="ServiceException">
        <part name="fault" element="tns:ServiceFault"/>
    </message>
    <portType name="AddressProcessor">
        <operation name="processAddress" parameterOrder="adrIn user digest nonce createdDate ticket accounting">
            <input wsam:Action="Test123/AddressProcessor/processAddressRequest" message="tns:processAddress"/>
            <output wsam:Action="Test123/AddressProcessor/processAddressResponse" message="tns:processAddressResponse"/>
            <fault message="tns:NotEnoughCreditsException" name="NotEnoughCreditsException" wsam:Action="Test123/AddressProcessor/processAddress/Fault/NotEnoughCreditsException"/>
            <fault message="tns:AuthenticationException" name="AuthenticationException" wsam:Action="Test123/AddressProcessor/processAddress/Fault/AuthenticationException"/>
            <fault message="tns:ValidationException" name="ValidationException" wsam:Action="Test123/AddressProcessor/processAddress/Fault/ValidationException"/>
            <fault message="tns:ServiceException" name="ServiceException" wsam:Action="Test123/AddressProcessor/processAddress/Fault/ServiceException"/>
        </operation>
    </portType>
    <binding name="AddressProcessorPortBinding" type="tns:AddressProcessor">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <operation name="processAddress">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="literal" parts="adrIn"/>
                <soap:header message="tns:processAddress" part="user" use="literal"/>
                <soap:header message="tns:processAddress" part="digest" use="literal"/>
                <soap:header message="tns:processAddress" part="nonce" use="literal"/>
                <soap:header message="tns:processAddress" part="createdDate" use="literal"/>
                <soap:header message="tns:processAddress" part="ticket" use="literal"/>
                <soap:header message="tns:processAddress" part="accounting" use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
            <fault name="NotEnoughCreditsException">
                <soap:fault name="NotEnoughCreditsException" use="literal"/>
            </fault>
            <fault name="AuthenticationException">
                <soap:fault name="AuthenticationException" use="literal"/>
            </fault>
            <fault name="ValidationException">
                <soap:fault name="ValidationException" use="literal"/>
            </fault>
            <fault name="ServiceException">
                <soap:fault name="ServiceException" use="literal"/>
            </fault>
        </operation>
    </binding>
    <service name="AddressProcessorService">
        <port name="AddressProcessorPort" binding="tns:AddressProcessorPortBinding">
            <soap:address location="https://webserviceUrl/ressource/soap/v1.1/"/>
        </port>
    </service>
</definitions>

Best regards.

1
  • The way to implement "write your own Apex" option is to first acquire the successful request/response to/from the web service outside of Salesforce - there are plenty of SOAP tools out there that will help you with this, do a search. You can then create Apex code to mimic the SOAP request.
    – identigral
    Sep 15, 2022 at 15:48

1 Answer 1

1

I'm one of the current maintainers of SFDC Explorer.

The reason the generated Apex classes do not validate is that your string types are namespaced to 'Test123' so they are expected to be custom types. If you replace all instances of type="string" with type="xsd:string" that will use the root namespace and generate the correct types in the Apex classes.

1
  • Thank you for your anwser Sir.
    – 0xLeouk
    Sep 19, 2022 at 7:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .