weboptions
指定 RESTful Web 服务的参数
说明
options = weboptions 返回一个默认 weboptions 对象,以指定 Web 服务请求的参数。weboptions 对象可以是 webread、websave 和 webwrite 函数的可选输入参量。有关 weboptions 函数不支持的选项,请参阅 使用 HTTP 从 MATLAB 调用 Web 服务。
options = weboptions( 指定 Name,Value)weboptions 对象的一个或多个属性。要从代码中删除敏感信息,请参阅 loadenv。
示例
默认的 weboptions 对象
创建一个默认的 weboptions 对象并显示其属性的默认值。
options = weboptions
options =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 9.7.0.1112323 (R2019b)'
Timeout: 5
Username: ''
Password: ''
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'auto'
RequestMethod: 'auto'
ArrayFormat: 'csv'
HeaderFields: []
CertificateFilename: 'default'weboptions 对象中的用户名和密码
在 weboptions 对象中设置您的 Web 服务用户名和密码。当 Web 服务要求进行身份验证时,您可以将 weboptions 对象用作 webread、websave 或 webwrite 的输入参量。通过使用 secretID 对象保持敏感信息加密。
options = weboptions(Username=secretID("MathWorks.Username"), ... Password=secretID("MathWorks.Password"))
options =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 25.1.0.2966447 (R2025a) Update 1'
Timeout: 5
Username: MathWorks.Username (secretID)
Password: MathWorks.Password (secretID)
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'auto'
RequestMethod: 'auto'
ArrayFormat: 'csv'
HeaderFields: []
CertificateFilename: 'default'
secretID 对象仅显示标识符名称。
options.Password
ans =
secretID with properties:
Name: "MathWorks.Password"
名称-值参数
版本历史记录
在 R2014b 中推出