webwrite returns status 405 "Method not Allowed"

조회 수: 13 (최근 30일)
Lane Bekow
Lane Bekow 2019년 2월 16일
편집: Madheswaran 2024년 11월 19일 9:05
Hi Everyone,
I work in x-ray scattering and have to reference various material properties often. I'd like to try to automate this process by being able to directly download the data from this online database and assign it to a variable or two in matlab. The issue I'm having is this database requires user input before it will lookup or calculate the needed results. Here is an example of this form: http://henke.lbl.gov/optical_constants/pert_form.html
I'd like a funtion in MATLAB that would take the two user intput 'Element' and 'Energy' and submit them to this form and return all the information under the 'Atomic Proeprties' and 'Material Properties' sections of the next page.
I've been quickly overwhelmed by the properties of webread/webwrite and all the RESTful web services or JSONs. All I've been able to do so far is read in the html file by calling
response = webread('http://henke.lbl.gov/optical_constants/pert_form.html')
From what I've read, it seems like this database is using POST to request data from the user, but I haven't been able to successfully post anything to this form. When I try to post with webwrite I get the following error
>> webwrite('http://henke.lbl.gov/optical_constants/pert_form.html','post',{'Element','Si'})
Error using readContentFromWebService (line 46)
The server returned the status 405 with message "Method Not Allowed" in response to the request to URL
http://henke.lbl.gov/optical_constants/pert_form.html.
Error in webwrite (line 139)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
I'm not sure what exactly the issue is or how to proceed. Any adviced is greatly appreciated.
  댓글 수: 1
J E
J E 2022년 9월 13일
편집: Rena Berman 2022년 9월 13일
I'm having the same issue - did you ever find a solution? Thanks! 2

댓글을 달려면 로그인하십시오.

답변 (1개)

Madheswaran
Madheswaran 2024년 11월 19일 9:05
편집: Madheswaran 2024년 11월 19일 9:05
I assume that you would like to get the X-Ray properties of the different elements from https://henke.lbl.gov/optical_constants/pert_form.html. However you are making a direct post call to the site, which the server rejects it. As you can notice from the website when you submit the querry, a post call with the filled form data is sent to https://henke.lbl.gov/cgi-bin/pert_cgi.pl.
You can get the X-Ray properties of the element with the following MATLAB Command:
data = "Element=Si&Energy=1000";
response = webwrite('https://henke.lbl.gov/cgi-bin/pert_cgi.pl', data);
For more information, refer to the following documentation: https://mathworks.com/help/matlab/ref/webwrite.html
Hope this helps!

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by