Problem with xmlread() and https

조회 수: 5 (최근 30일)
Ioannis Antonopoulos
Ioannis Antonopoulos 2016년 6월 23일
편집: Robert 2018년 10월 31일
Hi,
I want to parse a xml with using xmlread from a url which uses https protocol. I get the following problem : java.io.IOException: Server is not responding, it might not support the current protocol. Missing ServerHello. What can I do to fix this? I am using Matlab R2010a (64 bit) and I have Windows 7 (64 bit). Thnak you in advance.

답변 (1개)

Robert
Robert 2018년 10월 31일
편집: Robert 2018년 10월 31일
This could work if you have write access to the file: In command window, type
edit callSoapService
Then in the m-file, search for line
url = URL(endpoint);
Replace it with:
url = URL([], endpoint, sun.net.www.protocol.https.Handler)
Save and try again.
If that doesn't work, you could get the XML text in a string and parse that using undocumented MATLAB . Put the XML in a string by using the http protocol and webread:
% Use http protocol instead of https.
myUrl = regexprep(myUrl, 'https', 'http');
% Read the file into a string.
xmlString = webread(myUrl);
% From undocumented MATLAB:
try
% The following avoids the need for file I/O:
inputObject = java.io.StringBufferInputStream(xmlString); % or: org.xml.sax.InputSource(java.io.StringReader(xmlString))
try
% Parse the input data directly using xmlread's core functionality
parserFactory = javaMethod('newInstance','javax.xml.parsers.DocumentBuilderFactory');
p = javaMethod('newDocumentBuilder',parserFactory);
xmlTreeObject = p.parse(inputObject);
catch
% Use xmlread's semi-documented inputObject input feature
xmlTreeObject = xmlread(inputObject);
end
catch
% Fallback to standard xmlread usage, using a temporary XML file:
% Store the XML data in a temp *.xml file
filename = [tempname '.xml'];
fid = fopen(filename,'Wt');
fwrite(fid,xmlString);
fclose(fid);
% Read the file into an XML model object
xmlTreeObject = xmlread(filename);
% Delete the temp file
delete(filename);
end

카테고리

Help CenterFile Exchange에서 Structured Data and XML Documents에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by