Problem with xmlread() and https

5 次查看(过去 30 天)
Ioannis Antonopoulos
编辑: 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