Problem with xmlread() and https
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Robert
le 31 Oct 2018
Modifié(e) : Robert
le 31 Oct 2018
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
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!