Skip to content

XAware Community

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
XAware 5.6
Need Help
Webinars and Events
Advanced Tutorials
Webinars and Events

You are here: Home arrow Blogs

SOAPSalesforcecom 28 Apr 2008 6:52 PM
avatar
Salesforce Web Services by jpeters

While reviewing some support questions from our European Office and verifying the new Salesforce AddOn, I decided to grab our Salesforce wsdl and run a few tests. Below are a few snippets of information which might help you while using XAware 5.0.

 

Complete steps 1 - 3 of the Quick Start Guide to Generate your Salesforce Web Service WSDL.

 

http://www.salesforce.com/us/developer/docs/api/index.htm

 

After step #3, you are finished. The next step will be to develop the login BizComponent. Note: I used the partner wsdl.

 

Login

Use the login call to log in to the login server and start a client session. A client application must log in and obtain a sessionId and server URL before making any other API calls.

 

When a client application invokes the login call, it passes in a username and password as user credentials. Upon invocation, the Force.comAPI authenticates the credentials and returns the sessionId for the session, the user ID associated with the logged-in username, and a URL that points to the Force.comAPI to use in all subsequent API calls.

 

After logging in, a client application needs to perform these tasks:

 

  • Set the session ID in the SOAP header so that the Force.com API can validate subsequent requests for this session.
  • Specify the server URL as the target for subsequent service requests. You must change to the server URL, the login server only supports login calls.

 

Below is a BizDocument which calls the login SOAP BizComponent. I have created two parameters, username and password, which are passed to the login BizComp, login.xbc.

 

<?xml version="1.0" encoding="UTF-8"?>

<Document xmlns:xa="http://xaware.org/xas/ns1" xa:version="5.0" xa:on_error="xa-doc::/Document/Error" xa:visible="yes">

    <xa:input>

        <xa:param xa:name="username" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

        <xa:param xa:name="password" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

        <xa:param xa:name="queryString" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

    </xa:input>

    <Element xa:bizcomp="Salesforce/SOAP/login.xbc" xa:remove="yes" username="%username%" password="%password%" />

    <E2 xa:bizcomp="Salesforce/SOAP/querystring.xbc" xa:remove="yes" queryString="%queryString%" url="%xa-doc::/Document/XMLdata/url%" id="%xa-doc::/Document/XMLdata/id%" />

    <xa:response xa:data_path="xa-doc::/Document/XMLdata/Element" />

    <Error xa:include="no">

        <detail>$xavar:error_stack$</detail>

    </Error>

</Document>

 

Below is the login BizComp, login.xbc. In the SOAP request, we call login and pass in username and password. I have mapped three elements in the response, Element, url, and id.

  1. Element was mapped to review all data returned from the login call. (Not used)
  2. url has been mapped to server URL. Note: You must specify the server URL as the target for subsequent service requests. You must change to the server URL, the login server only supports login calls.
  3. id has been mapped to session ID. In subsequent service requests, session ID must be passed in the SOAP header so that the Force.com API can validate requests for this session.

 

<?xml version="1.0" encoding="UTF-8"?>

<SOAP xmlns:xa="http://xaware.org/xas/ns1" xa:bizdriver="C:/Testcases/Salesforce/SOAP/login.xdr" xa:bizcomptype="SOAP" xa:default_name="soap" xa:on_soap_fault="error" xa:visible="yes">

    <xa:input>

        <xa:param xa:name="username" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

        <xa:param xa:name="password" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

    </xa:input>

    <xa:description />

    <xa:request xa:soapAction="" xa:output_type="xml" xa:soapStyle="document" xa:soapUse="literal">

        <SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">

            <SOAPENV:Body>

                <urn:login xmlns:urn="urn:partner.soap.sforce.com">

                    <urn:username>%username%</urn:username>

                    <urn:password>%password%</urn:password>

                </urn:login>

            </SOAPENV:Body>

        </SOAPENV:Envelope>

        <xa:return>

            <SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">

                <SOAPENV:Body>

                    <urn:loginResponse xmlns:urn="urn:partner.soap.sforce.com">

                        <urn:result>

                            <urn:metadataServerUrl>string</urn:metadataServerUrl>

                            <urn:passwordExpired>boolean</urn:passwordExpired>

                            <urn:serverUrl>string</urn:serverUrl>

                            <urn:sessionId>string</urn:sessionId>

                            <urn:userId>stringstringstring</urn:userId>

                            <urn:userInfo>

                                <urn:accessibilityMode>boolean</urn:accessibilityMode>

                                <urn:currencySymbol>string</urn:currencySymbol>

                                <urn:orgDefaultCurrencyIsoCode>string</urn:orgDefaultCurrencyIsoCode>

                                <urn:organizationId>stringstringstring</urn:organizationId>

                                <urn:organizationMultiCurrency>boolean</urn:organizationMultiCurrency>

                                <urn:organizationName>string</urn:organizationName>

                                <urn:profileId>stringstringstring</urn:profileId>

                                <urn:roleId>stringstringstring</urn:roleId>

                                <urn:userDefaultCurrencyIsoCode>string</urn:userDefaultCurrencyIsoCode>

                                <urn:userEmail>string</urn:userEmail>

                                <urn:userFullName>string</urn:userFullName>

                                <urn:userId>stringstringstring</urn:userId>

                                <urn:userLanguage>string</urn:userLanguage>

                                <urn:userLocale>string</urn:userLocale>

                                <urn:userName>string</urn:userName>

                                <urn:userTimeZone>string</urn:userTimeZone>

                                <urn:userType>string</urn:userType>

                                <urn:userUiSkin>string</urn:userUiSkin>

                            </urn:userInfo>

                        </urn:result>

                    </urn:loginResponse>

                </SOAPENV:Body>

            </SOAPENV:Envelope>

        </xa:return>

    </xa:request>

    <xa:design>

        <xa:wsdl xa:operation="login" />

    </xa:design>

    <xa:response>

        <XMLdata>

            <Element xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xa:copy="xa-results::SOAPENV:Envelope" xa:visible="prune" />

            <url xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">%xa-results::SOAPENV:Envelope/SOAPENV:Body/urn:loginResponse/urn:result/urn:serverUrl%</url>

            <id xmlns:urn="urn:partner.soap.sforce.com" xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">%xa-results::SOAPENV:Envelope/SOAPENV:Body/urn:loginResponse/urn:result/urn:sessionId%</id>

        </XMLdata>

    </xa:response>

</SOAP>

 

Below is the login BizDriver, login.xdr. This BizDriver is only used for the login BizComp. Note: The URL is from the endpoint in the wsdl.

 

<?xml version="1.0" encoding="UTF-8"?>

<xa:bizDriver xmlns:xa="http://xaware.org/xas/ns1" xa:bizdrivertype="SOAP_HTTP" xa:version="5.0">

    <xa:description />

    <xa:http>

        <xa:url>https://www.salesforce.com/services/Soap/u/12.0</xa:url>

    </xa:http>

</xa:bizDriver>

 

 

Now, we will take the uri and id values returned from the login BizComp and pass those into the querystring BizComp/BizDriver. Note: The id must be passed in the SOAP header and the url is passed down to the BizDriver. The third parameter passed into the BizComp is querystring. This is the query passed in. In the example below, the string, SELECT count() FROM Contact, was passed in.

 

<?xml version="1.0" encoding="UTF-8"?>

<SOAP xmlns:xa="http://xaware.org/xas/ns1" xa:bizdriver="C:\Testcases/Salesforce/SOAP/T1.xdr" xa:bizcomptype="SOAP" xa:default_name="soap" xa:on_soap_fault="error" xa:visible="yes" url="%url%">

    <xa:input>

        <xa:param xa:name="queryString" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

        <xa:param xa:name="url" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

        <xa:param xa:name="id" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

    </xa:input>

    <xa:description />

    <xa:request xa:soapAction="" xa:output_type="xml" xa:soapStyle="document" xa:soapUse="literal">

        <SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">

            <SOAPENV:Header>

                <tns:SessionHeader xmlns:tns="urn:partner.soap.sforce.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

                    <tns:sessionId>%id%</tns:sessionId>

                </tns:SessionHeader>

                <tns:CallOptions xmlns:tns="urn:partner.soap.sforce.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

                    <tns:client xsi:nil="true" />

                    <tns:defaultNamespace xsi:nil="true" />

                </tns:CallOptions>

            </SOAPENV:Header>

            <SOAPENV:Body>

                <urn:queryAll xmlns:urn="urn:partner.soap.sforce.com">

                    <urn:queryString>%queryString%</urn:queryString>

                </urn:queryAll>

            </SOAPENV:Body>

        </SOAPENV:Envelope>

        <xa:return>

            <SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">

                <SOAPENV:Body>

                    <urn:queryAllResponse xmlns:urn="urn:partner.soap.sforce.com">

                        <urn:result>

                            <urn:done>boolean</urn:done>

                            <urn:queryLocator>string</urn:queryLocator>

                            <!--Zero or more repetitions:-->

                            <urn:records>

                                <urn1:type xmlns:urn1="urn:sobject.partner.soap.sforce.com">string</urn1:type>

                                <!--Zero or more repetitions:-->

                                <urn1:fieldsToNull xmlns:urn1="urn:sobject.partner.soap.sforce.com">string</urn1:fieldsToNull>

                                <urn1:Id xmlns:urn1="urn:sobject.partner.soap.sforce.com">stringstringstring</urn1:Id>

                            </urn:records>

                            <urn:size>int</urn:size>

                        </urn:result>

                    </urn:queryAllResponse>

                </SOAPENV:Body>

            </SOAPENV:Envelope>

        </xa:return>

    </xa:request>

    <xa:design>

        <xa:wsdl xa:operation="queryAll" />

    </xa:design>

    <xa:response>

        <XMLdata>

            <Element xmlns:urn="urn:partner.soap.sforce.com" xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xa:copy="xa-results::SOAPENV:Envelope/SOAPENV:Body/urn:queryAllResponse/urn:result/urn:size" />

        </XMLdata>

    </xa:response>

</SOAP>

 

Below is the querystring BizDriver, T1.xdr. This BizDriver uses the URI returned from the login BizComp.

 

<?xml version="1.0" encoding="UTF-8"?>

<xa:bizDriver xmlns:xa="http://xaware.org/xas/ns1" xa:bizdrivertype="SOAP_HTTP" xa:version="5.0">

    <xa:description />

    <xa:input>

        <xa:param xa:name="url" xa:datatype="string" xa:default="" xa:description="" xa:required="yes" />

    </xa:input>

    <xa:http>

        <xa:url>%url%</xa:url>

    </xa:http>

    <!--Do not modify the following XA-Designer element as it is used by XA-Designer wizard.-->

    <xa:designer>

        <xa:wizard_step xa:name="SOAP Connection Info">

            <xa:connection xa:wsdl_url="Salesforce/SOAP/wsdls/partner.wsdl" xa:service="SforceService" xa:port="Soap" />

        </xa:wizard_step>

    </xa:designer>

</xa:bizDriver>

 

And finally, below is the execution result of the BizDocument. Again, this is a count of the records in the Contact table. We have 20 contacts.

 

<Element xmlns:urn="urn:partner.soap.sforce.com" xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">

    <urn:size>20</urn:size>

</Element>

 

 



Trackback(0)
Comments (1)add comment

Write comment
You must be logged in to a comment. Please register if you do not have an account yet.

busy

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
Commercial
Free Training
QuickStart Packages
Image 4 Title
Image 5 Title

Polls

Which data source and BizComponent combinations do you most frequently use?
 

Blogs

Recent Entries

Visit XAware.com