




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、WebServicesAPI 快速入门教程什么时候应该使用WebServicesAPIS这个预建应用程序提供了强大的CRM功能。此外,S提供能够自定义预置的应用程序,以适应您的组织。但是,您的组织可能有复杂的业务流程,是由现有的功能支持。当这种情况下,在F平台为开发人员提供了实现自定义的方式去实现自己的业务需要。这些包括了WebservicesAPI,apex,Visualforce服务。WebServicesAPI使用 WebServicesAPI 创建,检索,更新或删除等帐目记录,自定义对象。API还允许您维护密码,执行搜索,等等。使用任何语言都可以支持 WebServicesAPI。Me
2、tadataAPI使用 MetadataAPI 来检索,部署,创建,更新或删除自定义信息,如自定义对象定义和页面布局为您的组织,。最常见的用法是从沙盒迁移或测试组织到生产组织的变化。MetadataAPI 是用于管理和建立自定义工具,可以管理 Metadatadata 模型,而不是数据本身。要创建,检索,更新或删除,例如帐户或线索记录,使用API来管理您的数据。最简单的方式来访问 MetadataAPI 中的功能是用在FIDE或F迁移工具。这些工具是建立在MetadataAPI之上, 并使用标准的Eclipse和Ant工具, 分别以简化与元数据API的工作任务。 在Eclipse平台为基础,在
3、FIDE提供了一个集成开发环境与程序员熟悉舒适的环境,让您的代码,编译,测试和部署在IDE本身所有。Apex使用 Apex 如果你希望:创建Web服务创建电子邮件服务执行复杂的验证多个对象创建复杂的业务流程所不支持的过程创建定制的事务逻辑(逻辑发生在整个交易,只需用一个单个记录或对象不)将自定义逻辑来一次手术,如保存记录,以便它在操作时发生执行,无论它在用户界面,Visualforce页,或从Web服务API起源VisualforceVisualforce 包括一个基于标记的标记语言,让开发人员构建应用程序和定制S 这个用户界面更强大的方法。随着 Visualforce 您可以:建立多步向导和
4、其它程序通过应用程序创建自己的自定义流程控制定义最佳,高效应用的交互导航模式和数据的具体规则支持的S版本使用API,您的组织必须使用企业版,开发版。如果您是现有的S的客户,并希望升级到企业或无限制版,请联系您的客户代表。开发Web服务客户端应用程序,强烈建议您使用开发人员测试,这是你的翻版S的部署,包括所有的定制和数据。符合标准SimpleObjectAccessProtocol(SOAP)1.1/TR/2000/NOTE-SOAP-20000508WebServiceDescriptionLanguage(WSDL)1.1/TR
5、/2001/NOTE-wsdl-20010315WS-IBasicProfile1.1/Profiles/BasicProfile-1.1-2004-08-24.html开发平台VisualStudio。NET2005中,和ApacheAxis1.3和JDK5.0(Java2平台标准版开发套件5.0)。快速启动第1步:获取S公司开发版帐户如果您还不是开发社区的成员,去http:/ WSDL 文件任何具有修改所有数据权限可以下载Web服务描述语言(WSDL)文件,整合和扩展S使用API的用户。(系统管理员有此权限配置文件。)WSDL文件是动态生成此基础上,对W
6、SDL文件(企业或合伙人)类型下载。生成的WSDL定义了所有的API调用,对象(包括标准和自定义对象),字段可用于您的组织的API访问。要生成您的组织的WSDL文件:1您必须登录以管理员或用户谁拥有嘴改所有数据的权限。登录进行检查,以确保他们从一个已知的IP地址2按一下您的姓名|设置|人才培养|API 显示下载网页的 WSDL如果您正在下载WSDL和你的企业在组织管理,按企业的WSDL生成安装包。S将提示您选择安装的软件包的每个要包括在生成的WSDL版本。否则,右键单击适当的WSDL文件,将它保存到本地目录的链接。在右键菜单,IE浏览器用户可以选择目标另存为3导入的WSDL文件到您的开发平台I
7、nstructionsforJavaEnvironments(ApacheAxis)WSDL2Java的基本语法是:java-classpathpathToJAR/Filenameorg.apache.axis.wsdl.WSDL2Java-apathToWsdl/WsdlFilenamejava-classpathc:axis-1.3libaxis.jar;c:axis-1.3libaxis-ant.jar;c:axis-1.3libaxis-schema.jar;c:axis-1.3libcommons-discovery-0.2.jar;c:axis-1.3libcommons-logg
8、ing-1.0.4.jar;c:axis-1.3libjaxrpc.jar;c:axis-1.3liblog4j-1.2.8.jar;c:axis-1.3libsaaj.jar;c:axis-1.3libwsdl4j-1.5.2.jar;c:axis-1.3mail.jar;c:axis-1.3activation.jar;c:axis-1.3wsdl4j.jar;org.apache.axis.wsdl.WSDL2Java-aC:mywsdlsmy_enterprise.wsdl4示例代码Java代码1 .S用户名和密码2 .调用login(),如果login成功a)设置返回到会话的Sess
9、ionIDheaderb)复位到返回的serverUrl,这是后续API调用目标端点3 .调用describeGlobal()来检索所有可用对象为该组织的数据列表。4 .调用describeSObject()来检索指定对象的元数据(字段列表和对象属性)。5 .调用查询(),传递一个简单的查询字符串(谜择名字,从联系姓氏b,并遍历返回QueryResult/Thesampleclientapplicationbeginsbyimportingthenecessarypackagesandobjects.packagecom.doc.samples;importjava.io.*;importja
10、va.rmi.RemoteException;importjavax.xml.rpc.ServiceException;importcom.sforce.soap.enterprise.*;importcom.sforce.soap.enterprise.fault.ExceptionCode;importcom.sforce.soap.enterprise.fault.LoginFault;|importcom.sforce.soap.enterprise.sobject.Contact;|/*Title:LoginSample* Description:Consoleapplication
11、illustratinglogin,sessionmanagement,*andserverredirection.* Copyright:Copyright(c)2005-2008* Company:* version14.0*/publicclassSamplesprivateSoapBindingStubbinding;staticBufferedReaderrdrInputStreamReader(System.in);publicSamples()publicstaticvoidmain(String口args)throwsServiceExceptionSamplessamples
12、1=newSamples();samples1.run();/Thesampleclientapplicationretrievestheuserslogincredentials./HelperfunctionforretrievinguserinputfromtheconsoleStringgetUserInput(Stringprompt)System.out.print(prompt);tryreturnrdr.readLine();catch(IOExceptionex)returnnull;)/*newBufferedReader(new* Thelogincallisusedto
13、obtainatokenfromSalesforce.* Thistokenmustbepassedtoallothercallstoprovide* authentication.* /privatebooleanlogin()throwsServiceExceptionStringuserName=getUserInput(Enterusername:);Stringpassword=getUserInput(Enterpassword:);/*Next,thesampleclientapplicationinitializesthebindingstub.* Thisisourmaini
14、nterfacetotheAPIthroughwhichall* callsaremade.ThegetSoapmethodtakesanoptionalparameter,* (.URL)whichistheendpoint.* Forthelogincall,theparameteralwaysstartswith* http(s):/.Afterloggingin,thesample* clientapplicationchangestheendpointtotheonespecified*inthereturnedloginResultobject.*/binding=(SoapBin
15、dingStub)newSforceServiceLocator().getSoap();|/Timeoutafteraminutebinding.setTimeout(60000);/TestoperationLoginResultloginResult;trySystem.out.println(LOGGINGINNOW.);loginResult=binding.login(userName,password);)catch(LoginFaultex)/TheLoginFaultderivesfromAxisFaultExceptionCodeexCode=ex.getException
16、Code();if(exCode=ExceptionCode.FUNCTIONALITY_NOT_ENABLED|exCode=ExceptionCode.INVALID_CLIENT|exCode=ExceptionCode.INVALID_LOGIN|exCode=ExceptionCode.LOGIN_DURING_RESTRICTED_DOMAIN|exCode=ExceptionCode.LOGIN_DURING_RESTRICTED_TIME|exCode=ExceptionCode.ORG_LOCKED|exCode=ExceptionCode.PASSWORD_LOCKOUT|
17、exCode=ExceptionCode.SERVER_UNAVAILABLE|exCode=ExceptionCode.TRIAL_EXPIRED|exCode=ExceptionCode.UNSUPPORTED_CLIENT)System.out.println(Pleasebesurethatyouhaveavalidusername+andpassword.);else/WritethefaultcodetotheconsoleSystem.out.println(ex.getExceptionCode();/WritethefaultmessagetotheconsoleSystem
18、.out.println(Anunexpectederrorhasoccurred.ex.getMessage();|returnfalse;catch(Exceptionex)System.out.println(Anunexpectederrorhasoccurred:ex.getMessage();|ex.printStackTrace();returnfalse;/Checkifthepasswordhasexpiredif(loginResult.isPasswordExpired()System.out.println(Anerrorhasoccurred.Yourpassword
19、hasexpired.);returnfalse;/*Oncetheclientapplicationhasloggedinsuccessfully,itwilluse*theresultsofthelogincalltoresettheendpointoftheservice*tothevirtualserverinstancethatisservicingyourorganization.*Todothis,theclientapplicationsetsENDPOINT_ADDRESS_PROPERTY*ofthebindingobjectusingtheURLreturnedfromt
20、heLoginResult.*/binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTYloginResult.getServerUrl();/*ThesampleclientapplicationnowhasaninstanceoftheSoapBindingStub*thatispointingtothecorrectendpoint.Next,thesampleclientapplication*setsapersistentSOAPheader(tobeincludedonallsubsequentcallsthat*
21、aremadewiththeSoapBindingStub)thatcontainsthevalidsessionId*forourlogincredentials.Todothis,thesampleclientapplication*createsanewSessionHeaderobjectandsetitssessionldpropertytothe*sessionldpropertyfromtheLoginResultobject.*/Createanewsessionheaderobjectandaddthesessionid/fromtheloginreturnobject_Se
22、ssionHeadersh=new_SessionHeader();sh.setSessionId(loginResult.getSessionId();the/*Next,thesampleclientapplicationcallsthesetHeadermethodofthe*SoapBindingStubtoaddtheheadertoallsubsequentmethodcalls.This*headerwillpersistuntiltheSoapBindingStubisdestroyeduntiltheheader*isexplicitlyremoved.TheSessionH
23、eaderparameteristhenameofthe*headertobeadded.|*/setthesessionheaderforsubsequentcallauthenticationbinding.setHeader(newSforceServiceLocator().getServiceName().getNamespaceURI(),SessionHeader,sh);/returntruetoindicatethatweareloggedin,pointed/attherighturlandhaveoursecuritytokeninplace.returntrue;/*
24、Todeterminetheobjectsthatareavailabletothelogged-inuser,thesample* clientapplicationexecutesadescribeGlobalcall,whichreturnsallofthe* objectsthatarevisibletothelogged-inuser.Thiscallshouldnotbemade* morethanoncepersession,asthedatareturnedfromthecalllikelydoesnot* changefrequently.TheDescribeGlobalR
25、esultissimplyechoedtotheconsole.* /privatevoiddescribeGlobalSample()tryDescribeGlobalResultdescribeGlobalResult=null;describeGlobalResult=binding.describeGlobal();DescribeGlobalSObjectResult口sobjectResults=describeGlobalResult.getSobjects();for(inti=0;i0)|System.out.println(Loggedinusercansee+qr.get
26、Records().length+contactrecords.);|do/outputcontactrecords|for(inti=0;i0);elseSystem.out.println(Norecordsfound.);getUserInput(Querysuccesfullyexecuted.nHitreturntocontinue.);catch(RemoteExceptionex)System.out.println(nFailedtoexecutequerysuccesfully,errormessagewas:+n+ex.getMessage();getUserInput(n
27、Hitreturntocontinue.);fromprivatevoidrun()throwsServiceExceptionif(login()getUserInput(SUCCESSFULLOGIN!Hittheenterkeytocontinue.);describeGlobalSample();describeSample();querySample();)C#SampleCodeThissectionwalksthroughasampleC#clientapplication.Thepurposeofthissampleapplicationistoshowtherequireds
28、tepsforlogginginandtodemonstratetheinvocationandsubsequenthandlingofseveralAPIcalls.Thissampleapplicationperformsthefollowingmaintasks:1.PromptstheuserfortheirSusernameandpassword.2.Callslogin()tologintothesingleloginserverand,iftheloginsucceeds:oSetsthereturnedsessionIdintothesessionheader,whichisr
29、equiredforsessionauthenticationonsubsequentAPIcalls.oResetstheFendpointtothereturnedserverUrl,whichisthetargetofsubsequentAPIcalls.AllclientapplicationsthataccesstheAPImustcompletethetasksinthisstepbeforeattemptinganysubsequentAPIcalls.3.CallsdescribeGlobal()toretrievealistofallavailableobjectsforth
30、eorganizationdescribeGlobalmethoddeterminestheobjectsthatareavailabletotheloggedinuser.Thiscallshouldnotbemademorethanoncepersession,sincethedatareturnedfromthecallisnotlikelytochangefrequently.TheDescribeGlobalResultisechoedtotheconsole.4.CallsdescribeSObject()toretrievemetadata(fieldlistandobjectp
31、roperties)foraspecifiedobject.ThedescribeSObjectmethodillustratesthetypeofmetadatainformationthatcanbeobtainedforeachobjectavailabletotheuser.ThesampleclientapplicationexecutesadescribeSObject()callonagivenobjectandthenechoesthereturnedmetadatainformationtotheconsole.Objectmetadatainformationinclude
32、spermissions,fieldtypesandlengths,andavailablevaluesforpicklistfieldsandtypesforreferenceTofields.5.Callsquery(),passingasimplequerystring(SELECTFirstName,LastNameFROMContact),anditeratingthroughthereturnedQueryResult.Inthefollowingsamplecode,APIcallsandothersignificantcodeareidentifiedinaboldfont.I
33、naddition,notetheerrorhandlingcodethatfollowseachAPIcall.sdata.TheThefollowingcodebeginsthesampleC#clientapplication.usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Web.Services.Protocols;usingWalkthrough.sforce;namespaceWalkthroughclassWalkthroughSampleprivateSforceServiceb
34、inding;staticprivateWalkthroughSamplewalkthroughSample;STAThreadstaticvoidMain(stringargs)walkthroughSample=newWalkthroughSample。;walkthroughSample.run();publicvoidrun()(/Callthelogincallif(login()(/DoadescribeglobaldescribeGlobal();/describeanaccountobjectdescribeSObject(account);/retrievesomedatau
35、singqueryquerySample();privateboollogin()(Console.Write(Enterusername:);stringusername=Console.ReadLine();Console.Write(Enterpassword:);stringpassword=Console.ReadLine();/Createaserviceobjectbinding=newSforceService();/Timeoutafteraminutebinding.Timeout=60000;/TrylogginginLoginResultlr;tryConsole.Wr
36、iteLine(LOGGINGINNOW.);lr=binding.login(username,password);/ApiFaultisaproxystubgeneratedfromtheWSDLcontractwhen/thewebservicewasimportedcatch(SoapExceptione)/WritethefaultcodetotheconsoleConsole.WriteLine(e.Code);/WritethefaultmessagetotheconsoleConsole.WriteLine(Anunexpectederrorhasoccurred:+e.Mes
37、sage);/WritethestacktracetotheconsoleConsole.WriteLine(e.StackTrace);/ReturnFalsetoindicatethattheloginwasnotsuccessfulreturnfalse;/Checkifthepasswordhasexpiredif(lr.passwordExpired)Console.WriteLine(Anerrorhasoccurred.Yourpasswordhasexpired.);returnfalse;/*Oncetheclientapplicationhasloggedinsuccess
38、fully,itwilluse* theresultsofthelogincalltoresettheendpointoftheservice* tothevirtualserverinstancethatisservicingyourorganization* /binding.Url=lr.serverUrl;/*ThesampleclientapplicationnowhasaninstanceoftheSforceService* thatispointingtothecorrectendpoint.Next,thesampleclient* applicationsetsapersi
39、stentSOAPheader(tobeincludedonall* subsequentcallsthataremadewithSforceService)thatcontainsthe* validsessionIdforourlogincredentials.Todothis,thesample* clientapplicationcreatesanewSessionHeaderobjectandpersistitto* theSforceService.AddthesessionIDreturnedfromthelogintothe* sessionheader*/binding.Se
40、ssionHeaderValue=newSessionHeader();binding.SessionHeaderValue.sessionId=lr.sessionId;/Returntruetoindicatethatweareloggedin,pointed/attherightURLandhaveoursecuritytokeninplace.returntrue;privatevoiddescribeGlobal()(/describeGlobalreturnsanarrayofobjectresultsthat/includestheobjectnamesthatareavaila
41、bletothelogged-inuserDescribeGlobalResultdgr=binding.describeGlobal();Console.WriteLine(nDescribeGlobalResults:n);/Loopthroughthearrayechoingtheobjectnamestotheconsolefor(inti=0;idgr.sobjects.Length;i+)(Console.WriteLine();)Console.WriteLine(nnHitentertocontinue.);Console.ReadLine(
42、);)privatevoiddescribeSObject(stringobjectType)/CallthedescribeSObjectpassingintheobjecttypenameDescribeSObjectResultdsr=binding.describeSObject(objectType);/Thefirstproperiteswewillechoareontheobjectitself/FirstwewilloutputsomeDescriptiveinfoontheobjectConsole.WriteLine(nnObjectName:+);if(d
43、sr.custom)Console.WriteLine(CustomObject);if(dsr.label!=null)Console.WriteLine(Label:+dsr.label);/nowthepermissionsontheobjectif(dsr.activateable)Console.WriteLine(Activateable);if(dsr.createable)Console.WriteLine(Createable);if(dsr.deletable)Console.WriteLine(Deleteable);if(dsr.queryable)Console.Wr
44、iteLine(Queryable);if(dsr.replicateable)Console.WriteLine(Replicateable);if(dsr.retrieveable)Console.WriteLine(Retrieveable);if(dsr.searchable)Console.WriteLine(Searchable);if(dsr.undeletable)Console.WriteLine(Undeleteable);if(dsr.updateable)Console.WriteLine(Updateable);/Nowwewillretrievemeta-dataa
45、bouteachofthefieldsfor(inti=0;i0)Console.WriteLine(tLength:+field.length);if(field.scale0)Console.WriteLine(tScale:+field.scale);if(field.precision0)Console.WriteLine(tPrecision:+field.precision);if(field.digits0)Console.WriteLine(tDigits:+field.digits);if(field.custom)Console.WriteLine(tThisisacust
46、omfield.);/Outputthepermissiononthisfield.if(field.nillable)Console.WriteLine(tCanbenulled.);if(field.createable)Console.WriteLine(tCreateable);if(field.filterable)Console.WriteLine(tFilterable);if(field.updateable)Console.WriteLine(tUpdateable);/Ifthisisapicklistfield,wewillshowthevaluesif(field.ty
47、pe.Equals(fieldType.picklist)(Console.WriteLine(tPicklistValues);for(intj=0;jfield.picklistValues.Length;j+)Console.WriteLine(tt+field.picklistValuesj.value);)/Ifthisisaforeignkeyfield(reference),/wewillshowthevaluesif(field.type.Equals(fieldType.reference)(Console.WriteLine(tCanreferencetheseobjects:);for(intj=0;j0)Console.WriteLine(Logged-inusercansee+qr.records.Length+contactrecords.);while(!done)Console.WriteLine();for(inti=0;iqr.records.Length;i+)Contactcon=(Contact)qr.recordsi;stringfName=con.FirstName;stringlName=con.LastName;if(fName=null
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 软件测试工具的使用与效果评估试题及答案
- 计算机四级网软件测试技术的应用试题及答案
- 石油开采业的环境保护与生态文明建设考核试卷
- 监理师考试思维导图的使用技巧试题及答案
- 网络技术应急响应机制试题及答案
- 硝酸铈制备工艺与稀土材料研究考核试卷
- 网络技术考试知识点查缺补漏的关键试题及答案
- 金属废料加工绿色制造技术研究考核试卷
- 通信原理与终端设备基础考核试卷
- 数据库性能测试方法试题及答案
- 理论联系实际谈一谈如何维护政治安全?参考答案1
- 2025年中国冷库用叉车数据监测研究报告
- 2025年高考第二次模拟考试物理(浙江卷)(参考答案)-20250416-113627
- 2025年化妆师职业技能考试试题及答案
- 人工智能设计伦理知到智慧树章节测试课后答案2024年秋浙江大学
- 《陆上风电场工程概算定额》NBT 31010-2019
- 干部人事档案转递单表样
- 关于中国文化遗产北京故宫的资料
- 新中考考试平台-考生端V2.0使用手册
- 特困人员救助供养政策解读PPT课件
- (完整word版)400字作文稿纸A4打印模板
评论
0/150
提交评论