How Can I Authenticate a web service that requires username and password

5 ビュー (過去 30 日間)
I created a webservice in Matlab using a WSDL file, ( all methods were created successfully. However I have been trying to call the webservice but i keep getting the error below. How can I include my username and password in the code for authentication
Error using callSoapService (line 147)
Unspecified Fault: Java exception occurred:
java.lang.NullPointerException
at
com.mathworks.net.transport.MWTransportClientPropertiesFactory$1.getPasswordAuthentication(MWTransportClientPropertiesFactory.java:86)
at java.net.Authenticator.requestPasswordAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.privilegedRequestPasswordAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
Error in MeteredDataService/GetReadingsForRegisterByDate (line 41)
response = callSoapService( ...
Error in trywebservice (line 27)
value=GetReadingsForRegisterByDate(service,registerId,startDateTime,endDateTime, options);

採用された回答

Shruti Sapre
Shruti Sapre 2015 年 9 月 4 日
Hi Muyiwa,
I understand that you are trying to include the username and password in the code for authentication. I was reading about the same in the documentation, and it looks like you can pass the same in MATLAB R2015b through the “options” object in “matlab.wsdl.createWSDLClient”. This functionality, however, doesn’t seem to be present in the earlier functions of MATLAB. Here is the link that explains the same:
Hope this helps!
-Shruti
  2 件のコメント
Muyiwa Oyinlola
Muyiwa Oyinlola 2015 年 9 月 4 日
Many thanks for this, I was just about to give up!
Muyiwa Oyinlola
Muyiwa Oyinlola 2015 年 9 月 9 日
This works for creating the WSDL methods, however, this functionality doesn't seem to work when calling the web service. This is stated in the documentation link above -" ...The options also do not apply to requests made to servers by the generated code".
Any ideas how I can work round this? i.e how can i include the username and password in the call

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by