如何在Web服务调用中输入凭据(授权对象)? [英] How to enter credentials (Authorize object) in a web service call?

查看:262
本文介绍了如何在Web服务调用中输入凭据(授权对象)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了此处提供的建议,并且它奏效了像个魅力.现在,我正在连接到服务器并调用名为 GetFunctionalityTest 的方法.唯一输入的是字符串,可以在 GetFunctionalityTest.m 文件中看到.到目前为止一切顺利.

I followed the advice provided here and it worked like a charm. Right now, I'm connecting to the server and calling a method named GetFunctionalityTest. The only input to it is a string, which can be seen in the GetFunctionalityTest.m file. So far so good.

然后,我尝试调用名为 GetSections 的真实服务,该服务根据文件 GetSections.m 的签名如下.

Then I attempted to call the real service named GetSections whose signature according to the file GetSections.m is as follows.

function GetSectionsResult = GetSections(obj,auth)
% GetSections(obj,auth)
% Input: auth = (Authorize)
% Output: GetSectionsResult = (ArrayOfString)

values = { auth, };
names = { 'auth', };
types = { '{WSPro.HostingWebservice}Authorize', };

soapMessage = createSoapMessage( ...
  'WSPro.HostingWebservice', ...
  'GetSections', values,names,types,'document');
response = callSoapService( obj.endpoint, ...
  'WSPro.HostingWebservice/GetSections', soapMessage);
GetSectionsResult = parseSoapResponse(response);

服务器提供的定义如下.

The definition provided by the server is as follows.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi=...>
  <soap:Body>
    <GetSections xmlns="WSPro.HostingWebservice">
      <auth>
        <uid>string</uid>
        <pw>string</pw>
      </auth>
    </GetSections>
  </soap:Body>
</soap:Envelope>

我的问题是我无法指定授权语法.据我了解,它应该由两个字符串组成不知何故,但我还没有开始使用它.我已经尝试将这些内容合成如下.

My problem is that I can't specify the authorization syntax-wise. As far I understand, it's supposed to consist of two strings somehow but I haven't get it to work. I've tried to compound those as follows.

myAuthorization = ['user', 'pass'];
myAuthorization = {'user', 'pass'};
myAuthorization = ['user' 'pass'];
myAuthorization = {'user' 'pass'};

没有任何帮助.我只是有很多错误.

Nothing helped. I just got a bunch of errors.

使用callSoapService时出错(第147行)
未指定的错误:SOAP错误:服务器无法处理请求.
--->参数化查询
'(@uid nvarchar(99))从UserData中选择密码WHERE UserId = @'期望使用未提供的参数'@uid'.

Error using callSoapService (line 147)
Unspecified Fault: SOAP Fault: Server was unable to process request.
---> The parameterized query
'(@uid nvarchar(99)) SELECT PassW FROM UserData WHERE UserId = @' expects the parameter '@uid', which was not supplied.

我浏览了为我自动创建的所有文件,没有 Authorize 而不是 ArrayOfString 的定义.我猜这是服务器定义的东西,因为我在MatLab文档中没有发现任何问题.

I've browsed all the files automatically created for me and there's no definition of Authorize not ArrayOfString. I'm guessing it's something that the server defines, since I get no hits on those in MatLab documentation.

  1. 如何指定授权凭证?
  2. 我在哪里可以找到MatLab如何映射授权?

推荐答案

如上所述:

SOAP身份验证是通过SOAP Header而不是SOAP Body进行的.此链接可以让您大致了解在身份验证的情况下SOAP XML的外观:

The SOAP Authentication happens through SOAP Header and not SOAP Body.This link might give you an idea of how SOAP XML should look in case of authentication :

Web服务肥皂标头身份验证

这篇关于如何在Web服务调用中输入凭据(授权对象)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆