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

简介: 如何创建能够支持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.


image.png


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.


image.png


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:



image.png


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


image.png


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.


image.png


Implement BAdI to consume the web service

Create a BAdI implementation via the customizing activity below:


image.png


You could refer to my implementation code below:

image.png

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.


image.png

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:


image.png


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:


image.png



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


image.png


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.



相关文章
在 CRM WebClient UI Attachment 区域,创建支持 Web Service 的 Word 文档
在 CRM WebClient UI Attachment 区域,创建支持 Web Service 的 Word 文档
|
3天前
|
缓存 JavaScript 前端开发
JavaScript进阶 - Web Workers与Service Worker
【7月更文挑战第4天】JavaScript的Web Workers和Service Worker增强了Web性能。Web Workers处理后台多线程,减轻主线程负担,但通信有开销,受同源策略限制。Service Worker则用于离线缓存和推送通知,需管理其生命周期、更新策略,并确保安全。两者都带来了挑战,但也极大提升了用户体验。通过理解和优化,开发者能构建更高效、安全的Web应用。
|
1月前
|
JavaScript 前端开发 定位技术
Rest风格WEB服务(Rest Style Web Service)的真相
Rest风格WEB服务(Rest Style Web Service)的真相
39 1
|
2月前
|
JavaScript Java 测试技术
基于springboot+vue.js的基于Web教师个人成果管理系统附带文章和源代码设计说明文档ppt
基于springboot+vue.js的基于Web教师个人成果管理系统附带文章和源代码设计说明文档ppt
30 7
|
1月前
|
JavaScript 前端开发 Java
基于SpringBoot+Vue+uniapp的在线开放课程的Web前端的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的在线开放课程的Web前端的详细设计和实现(源码+lw+部署文档+讲解等)
|
2月前
|
XML API 网络架构
Web Service和Web API理解和使用场景
**Web Service**是一种基于网络、使用SOAP协议和XML的数据封装的重服务,适用于跨平台、跨语言的企业系统集成,尤其在安全性和事务处理严格的场景,如银行系统。而**Web API**是轻量级的HTTP接口,常遵循REST原则,使用JSON格式,适合移动应用、开放平台和微服务间的通信,因其简洁高效。选择哪种取决于项目需求,Web Service适合复杂交互,Web API则流行于现代Web应用。
|
2月前
|
缓存 应用服务中间件 数据库
Python Web Service开发及优化
随着互联网的快速发展,Web服务已成为现代技术的核心。Python作为一种功能强大且易于学习的编程语言,在Web服务开发领域占据着重要地位。Python Web服务开发的重要性在于它能够提供高效、可扩展且易于维护的解决方案。本篇博客将探讨如何使用Python的Flask框架、Gunicorn WSGI服务器和Nginx网页服务器来实现高性能的Web服务。
|
2月前
|
JavaScript Java 测试技术
基于Java的web新闻流媒体平台的设计与实现(源码+lw+部署文档+讲解等)
基于Java的web新闻流媒体平台的设计与实现(源码+lw+部署文档+讲解等)
30 0
|
2月前
|
XML 网络架构 数据格式
Ruby 教程 之 Ruby Web Service 应用 - SOAP4R 2
Ruby Web Service 应用 - SOAP4R
38 5
|
2月前
|
XML 存储 数据格式
如何在 CRM Assignment block 里创建支持 Web Service 的 PDF 附件
如何在 CRM Assignment block 里创建支持 Web Service 的 PDF 附件