How to enter credentials (Authorize object) in a web service call?

不打扰是莪最后的温柔 提交于 2019-12-23 15:01:06

问题


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.

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.

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.

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. How can I specify the credentials for authorization?
  2. Where can I look up how MatLab maps Authorization?

回答1:


As noted above:

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 service soap header authentication



来源:https://stackoverflow.com/questions/14848470/how-to-enter-credentials-authorize-object-in-a-web-service-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!