在 MATLAB 中使用 Apache CXF

发布于 2024-09-12 01:00:00 字数 406 浏览 2 评论 0原文

MATLAB 中的函数 createClassFromWsdl 有一些重大限制,就像不支持属性一样。在我看来,Apache CXF 生成 动态客户端 的能力可能是一种以相对用户友好的方式访问更广泛的 SOAP 端点的方法。只需将适当的 JAR 文件添加到 MATLAB 类路径中,您就可以从 MATLAB 命令行以交互方式创建强大的客户端。有人试过这个吗?有人可以举个例子吗?

The function createClassFromWsdl in MATLAB has some significant limitations, like not supporting attributes. It seems to me that the ability of Apache CXF to generate dynamic clients could be a way to access a wider variety of SOAP endpoints in a relatively user-friendly way. Simply adding the appropriate JAR files to your MATLAB classpath would allow you to interactively create robust clients from the MATLAB command line. Has anyone tried this? Would someone please provide an example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒路情人 2024-09-19 01:00:00

createclassfromwsdl 的功能确实有限。因此,我尝试了两个来自 Matlab 的用于 SOAP 通信的 java 包。

  • Apache CXF - 编译过程中出现了一些问题,因此我使用了第二种替代方案:
  • Axis2:这在 Matlab 中运行得很好,我执行了以下步骤:

1)安装 Axis2-1.5.4

2)./wsdl2java.sh - uri http://webservice:port.. -o outfolder -uw

3)然后我必须修复生成存根以避免肥皂通信期间出现一些错误(您可能不需要它):
- 将 SOAP12Constants 的出现替换为 SOAP11Constants

4)使用 ant 复制输出文件夹中的源

5)然后在 Matlab 中我使用以下初始化过程(假设 package.jar 是在 matlabpath 中,包位于folder_foo)

if isempty(strfind(javaclasspath,'package.jar')) % check whether the jar package is already in javapath
r = matlabpath;
tokens = strtok(r,pathsep);
found = 0;
[p, remain] = strtok(r,pathsep);
while p
    if not(isempty(regexp(p, 'folder_foo', 'ignorecase')))
        javaaddpath([ p filesep 'package.jar'] ); % add to dynamic java path
        import eu.package.name; 
        h = StubConstructor(); %instantiate the object
        found = 1;
        break;
    end
    p = strtok(remain,r);
end
if not(found)
    error('WS client initialization failed')
end
end

createclassfromwsdl has really limited functionality. Therefore I tried two java packages for SOAP communication from Matlab.

  • Apache CXF - there were some problems during compilation and therefore I used the second alternative:
  • Axis2: this worked quite well from Matlab, I performed following steps:

1)Install Axis2-1.5.4

2) ./wsdl2java.sh -uri http://webservice:port.. -o outfolder -uw

3) Then I had to fix the generated stubs in order to avoid some errors during soap communication (you might not need it):
- replace occurence of SOAP12Constants by SOAP11Constants

4)copile the sources in output folder using ant

5)Then in Matlab I use the following initialization procedure (assuming that the package.jar is in matlabpath and package is located in folder_foo)

if isempty(strfind(javaclasspath,'package.jar')) % check whether the jar package is already in javapath
r = matlabpath;
tokens = strtok(r,pathsep);
found = 0;
[p, remain] = strtok(r,pathsep);
while p
    if not(isempty(regexp(p, 'folder_foo', 'ignorecase')))
        javaaddpath([ p filesep 'package.jar'] ); % add to dynamic java path
        import eu.package.name; 
        h = StubConstructor(); %instantiate the object
        found = 1;
        break;
    end
    p = strtok(remain,r);
end
if not(found)
    error('WS client initialization failed')
end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文