转:SAP WEB Service

来源:互联网 发布:网络视频下载神器 编辑:程序博客网 时间:2024/06/06 11:47

转自:http://bbs.vsharing.com/Article.aspx?aid=727349

 

SAP WEB Service

 

创建 Web ServicesSAP
sap Web Services 
   Web service
就是一个应用程序,它向外界暴露出一个能够通过Web进行调用的API。也就是说,可以利用编程的方法通过Web来调用这个应用程序。
   Web services
是建立可互操作的分布式应用程序的新平台。Web service平台是一套标准,它定义了应用程序如何在Web上实现互操作性。你可以用任何你喜欢的语言,在任何你喜欢的平台上写Web service ,只要我们可以通过Web service标准对这些服务进行查询和访问。

SAP
Web Service 分为ABAP and Java Web Services


创建Web Service
方法1.T-Code:SE80 选择Package,然后右击在菜单中选择,Create®Enterprise Services / Web Services ® Web Service.
方法2.T-CODE SE37 选择一个function module,显示,菜单,Utilities®More Utilities®Create Web Service® From the Function Moduleor From the Function Group
方法3.T-CODEBAPI  BAPI Explorer


在创建Web service 时,首先要创建Virtual interfaces
Virtual interfaces
Using virtual interfaces, you can define several views of an implementation and publish these separately as a Web service. When you create virtual interfaces, you can rename or hide operations and parameters. You can also define standard values for parameters and convert parameter types.
创建Virtual interfaces
T-CODE
SE80    选择Package 右击:Create®Enterprise Service / Web Service®Virtual Interface


Release Web Service
T-CODE:WSConfig
选择web service Service Definition ,Variant
创建 release web service.
保存后列表中会出现已release web service.

生成WSDL
T-CODE:WSADMIN
执行(Ctrl+F8),生成WSDL(Web Services Description Language)Ctrl+F9)
服务管理
T-CODE:sicf 
管理SAP服务(包含web service)
服务监控:
T-Code:smicm
服务监控
 
 
SAP.NET 实现 XI SOAP Sender
SAP.NET可以实现与SAP系统的IDOCFMBAPIRFC web service方式的连接,进行交互,其中web service是未来SAP与外界进行交互技术发展的趋势,也是ESOA的实现之一。


开发步骤:
这个实例使用BAPI_USER_GET_DETAIL 做为receiver interface 和用户定义outbound 同步interface

创建response message mapping

创建interface mapping

创建sender communication channel  类型是SOAP adapter ,使用outbound synchronous interface


创建 receiver communication channel

创建receiver determination

ID端定义web service,创建WSDL outbound synchronous ,URL http://host:port/XISOAPAdapter/MessageServlet?channel=party:service:channel


.net 开发环境下加入web 引用,可以用本地文件,或者远程URL


编译后会生成CS的类文件,关于sap.net 的应用可以查看sap.net安装后的DEMO,很好,很强大。
 
 
一、生成webservice
1、向导创建:SE37, Utilities -> More Utilities -> Create Web Service -> From the Funtion Module
2、或者: SE80, 在Package的右键菜单中选择:Create -> Enterprise Service / Web Service -> Web Service
3、详细配置:SE80
4、运行环境配置:WSCONFIG
5、Web Servie Administration for SOAP Runtime: WSADMIN, 在这里可以做webservice的测试,查看WSDL
 
二、调用webservice
1、创建RFC连接: SM50, 类型为HTTP Connection to External Serv,可以设置登录用户和口令
2、创建Logical Port: LPCONFIG, 其中HTTP Destination 选择上一步创建的RFC连接,Path Prefix选择WSDL路径中的后半部分,保存后Active
3、修改调用程序使用的Package, 增加两个Use Access, SAI_TOOLS和SAPPINT, Error Severity都选择No Response
4、生成代理对象: SE80,在Enterprise Services节点的右键菜单中选择: Create -> Proxy Object, WSDL Soruce选择URL / HTTP Destination, 输入WSDL的地址就可以了
5、写调用代码,生成一个代理对象的实例,再调用它的方法就可以了,下面是一个简单的例子:
 
REPORT z_ws_call_test.
DATA: proxy TYPE REF TO zco_z_get_org,
      org_in TYPE zzget_org,
      org_out TYPE zzget_org_response,
      error type REF TO cx_ai_system_fault.
 
org_in-orgname = 'SORG.1000'.
 
TRY.
    CREATE OBJECT proxy
* EXPORTING
*    LOGICAL_PORT_NAME =
        .
*TRY.
    CALL METHOD proxy->zget_org
      EXPORTING
        input = org_in
      IMPORTING
        output = org_out.
* CATCH CX_AI_SYSTEM_FAULT .
* CATCH CX_AI_APPLICATION_FAULT .
*ENDTRY.
 
CATCH cx_ai_system_fault INTO error.
    WRITE /1 error->ERRORTEXT.
ENDTRY.
 
WRITE: AT /1 org_in-orgname,
          /1 org_out-orgcode.
Building Web Services with ABAP and SAP Web Application Server.pdf ( 1376 KB )
原创粉丝点击