`
JerryWang_SAP
  • 浏览: 1001312 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

如何创建能够支持Web Service的Word文档

阅读更多

In these two documents below, I have demonstrated the steps how to create word or PDF document as attachments which could consume web service created via CRM web service tool.

(1) Create Webservice enabled Adobe PDF attachment in CRM Application (2) Create Webservice enabled word document in attachment assignment block

As we could find in document template creation UI, there is a third option which allows us to assign a WSDL URL of an external web service to a document template. So this document will explain how to create a word template which could consume your own web service, instead of the one created via CRM web service tool.

 

 

Ensure you have a working web service

for simplicity I just create a simple function module which do the add operation and expose it into web service with tcode SOAMANAGER.

 

 

In order to consume it, An ABAP proxy is needed. Test the ABAP consumer proxy in ABAP workbench and make it work, since it will be used later:

 

 

You could use this document as reference about how to expose a function module into web service via SOAMANAGER and the necessary configuration to consume it in ABAP.

Create word template and assign your web service WSDL to it

In document creation UI, choose radio box “Own WSDL URL”, paste your web service WSDL URL to input field and press entry key, then your web service operation will appear in drop down list automatically. Choose your operation and click button “Start Designer”. If you meet with 401 unauthorization error message after enter key is pressed, refer to this document about solution:

How to resolve Unauthorized error message when defining external web service for document template

 

 

Now a new word document is opened. You could drag the output variable EV_RESULT from SAP Data panel to your word body area. Its content will be filled by your web service in the runtime. Finish the template development.

 

 

Implement BAdI to consume the web service

Create a BAdI implementation via the customizing activity below:

 

 

You could refer to my implementation code below:

DATA: lo_proxy            TYPE REF TO co_zweb_add_21,
ls_input            TYPE zweb_add_operation,
ls_output           TYPE zweb_add_operationresponse,
lo_payload_protocol TYPE REF TO if_wsprotocol_payload,
lo_payload          TYPE REF TO if_ws_payload,
lo_payload_handler  TYPE REF TO if_ws_payload_handler,
lt_request_data     TYPE prx_t_param,
ls_request_data     TYPE prx_s_param,
lv_valid_from       TYPE comt_valid_from.

line 17: Create an instance of ABAP consumer proxy class. line 21: The current business object instance GUID is included in importing parameter IS_OBJECT-INSTID. Since my word template is created based on BOR type BUS1178, so I could directly query product database table COMM_PRODUCT to find the corresponding product record.

line 24 ~ 27: I just fetch the valid from timestamp of current product and pass the date value to the first importing parameter of web service call. The second importing parameter is assigned with 0, so in the final word document we will see the valid from date of current product.

line 28: execute web service call, the result is included in parameter ls_output. line 38 and 39: pass out the web service response payload to changing parameter, which will be used by Office integration framework to merge with word template.

 

 

Test in UI

Now you could create attachment based on your word template by clicking button “With Template”. Choose the word template you have just developed from pop up window:

 

 

you could still set breakpoint in your BAdI implementation and the function module exposed as web service to observe how they are consumed in the runtime:

 

 

Finally the web service calculation result is displayed in the word document.

 

 

Further reading

If you would like to know how a word template is merged with data from xml file, you can find technical detail in this document Understand how the word template is merged with xml data stream.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

0
0
分享到:
评论

相关推荐

    web service business process execution language

    BPEL 2.0在先前版本的基础上增加了许多新特性,包括对Web服务上下文(Web Service Context)的支持,以及对事件处理和多方交易的改进。BPEL的版本历史还包括1.1版本和一个正在维护的草案版本。WSDL(Web服务描述语言...

    springboot word文件导出实例

    在Spring Boot框架中,开发人员经常需要处理文件的导入与导出操作,特别是Word文档,因为Word格式在商业环境中广泛用于报告、合同和其他正式文档。本教程将深入探讨如何在Spring Boot项目中实现Word文件的导出功能。...

    ASP.NET生成WORD文档服务器部署注意事项

    本文将详细介绍如何解决这些常见的配置问题,包括错误代码80070005和8000401a的问题,并提供具体的步骤来确保ASP.NET应用程序能够顺利地创建和操作Word文档。 #### 错误代码80070005: 检索 COM 类工厂中 CLSID 为 {...

    java实现word预览打印

    3. **动态生成模板Word文件**: 这个过程通常涉及到使用Java库,如Apache POI或Spire.Doc,来创建和编辑Microsoft Word文档。开发者可以通过这些库读取、修改和生成Word模板,填充数据,自动化文档的生成过程。 4. *...

    在线文档预览,支持ppt,word,excel在线预览

    **OpenOffice** 是一个开源的办公软件套件,它不仅支持创建、编辑和保存各种办公文档,还提供API供开发者使用。在本项目中,OpenOffice作为后台转换工具,负责将接收到的文档(如ppt、doc、xls等)转换为通用的PDF...

    web+Service开发

    - **XFire**:XFire是一个轻量级的Web服务框架,它提供了创建和调用Web服务的简便方法。XFire支持多种数据绑定技术,使得开发者能够更容易地处理复杂的数据类型。 - **CXF**:Apache CXF是一个强大的框架,用于构建...

    JAVA面试题目集合word文档

    这份"JAVA面试题目集合word文档"涵盖了多个关键领域,包括Java基础、Servlet、JDBC与JDO、EJB、J2EE、MVC架构以及设计模式和JavaScript。下面将详细讨论这些领域的重点知识。 首先,Java基础是任何Java开发者必须...

    cxf教程(word)

    【压缩包子文件的文件名称列表】中的"WebService CXF学习.doc"可能是教程的主要部分,详细阐述了CXF框架在Web Service开发中的应用,包括基本概念、环境配置、服务的创建和部署、客户端调用等步骤。"cxf常用.jar包 ....

    springboot-poi-word-master_word_DEMO_POI_

    - 使用POI库,开发者可以创建、修改、读取Word文档,实现数据的导入导出,例如在Web应用中生成报表或合同。 3. **Word文档处理**: - XWPFDocument是Apache POI用来处理.docx文件的主要类。通过创建XWPFDocument...

    WebOffice接口

    参数`doctype`用于指定文档类型,例如"doc"代表Word文档,"xls"代表Excel文件。当文件路径为空字符串时,WebOffice通常会打开一个空白的新文档。 3. **显示打印对话框** `showPrintDialog` 函数会显示Office应用...

    eclipse8整合axis2word文档

    此外,对于服务端的部署,确保正确配置了Web工程的`web.xml`文件,使得Axis2服务引擎能够正确启动并识别服务。 总之,整合Eclipse8与Axis2主要是为了方便地在IDE中开发、部署和测试Web服务。通过以上步骤,开发者...

    Springboot+freemarker生成word

    接下来,我们需要创建一个FreeMarker模板文件(例如:`template.ftl`),定义Word文档的结构和内容。FreeMarker模板语言允许我们使用变量和控制结构来动态生成文档。例如: ```ftl <!DOCTYPE html> ${title} ${...

    H5页面生成word文件及发送邮件

    标题 "H5页面生成word文件及发送邮件" 涉及到的是在Web开发中将HTML5(H5)页面内容转换成Microsoft Word文档,并利用编程方式发送电子邮件的过程。这个技术通常用于自动化报告生成、数据导出或者在线服务中的文件...

    c#调用word功能.docx

    - 使用`Documents.Add`方法根据指定的模板创建新的Word文档。 - 这里需要注意的是,模板文件的路径应使用`Server.MapPath`方法转换为物理路径。 3. **操作文档内容**: - 通过`Bookmarks`集合找到指定书签(例如...

    Linux环境下配置同步更新的SVN服务器(word文档)

    这样的配置不仅能够方便团队成员之间进行代码的共享和协作,同时也能够自动将最新的代码部署到Web服务器上,极大地提高了开发效率和项目的维护性。此外,通过使用Apache作为前端服务器,我们还可以轻松地对SVN服务器...

    (完整word版)Web应用开发规范.doc

    这份"(完整word版)Web应用开发规范.doc"详细阐述了多个关键方面,包括文件编码格式、目录结构、编程规范、异常处理以及数据校验等,以指导开发人员遵循统一的标准进行开发。 1. **文件编码格式** - 项目默认采用...

    pb11+webservice 分布式三层应用实现说明word

    1. **PB11与Web Service的集成**:介绍如何在PB11环境中创建和调用Web Service,可能涉及SOAP和WSDL(Web Service Description Language)的概念。 2. **表示层设计**:在PB11中创建用户界面,解释如何设计和实现与...

    JAVA Spring框架实现登陆查询 完整搭建框架方法的word文档 包含mysql文件

    1 创建web项目,创建dao包,service包,pojo包,controller包,mapper包, 2 导入架包,将架包导入到项目的lib 文件中,如图 3 导入配置文件,将如下配置文件导入到src下面 3.1 修改generatorConfig.xml文件,这个...

    Servlet 中文版帮助文档(word格式,对付一般应用足够了)

    虽然文件格式是Word,但对于处理一般的Servlet应用需求,它已经足够提供了丰富的信息。 在"Servlet函数介绍.doc"中,你可能找到关于以下内容的详细说明: 1. **Servlet接口**:Servlet接口是所有Servlet类的基础,...

Global site tag (gtag.js) - Google Analytics