我正在尝试使用以下 MATLAB 代码连接到http://www.webservicex.net/上的示例肥皂服务器:
% createSoapMessage(NAMESPACE,METHOD,VALUES,NAMES,TYPES,STYLE) creates a SOAP message.
% VALUES, NAMES, and TYPES are cell arrays.
m = createSoapMessage('http://www.webserviceX.NET', 'GetCitiesByCountry', ...
{'Australia'}, {'CountryName'}, { '{http://www.w3.org/2001/XMLSchema}string' }, 'rpc')
% callSoapService(ENDPOINT,SOAPACTION,MESSAGE) sends the MESSAGE,
% a Java DOM, to the SOAPACTION service at the ENDPOINT.
response = callSoapService('http://www.webservicex.net/globalweather.asmx?WSDL', ...
'http://www.webserviceX.NET/GetCitiesByCountry', m);
我得到以下响应(插入行尾以供查看):
val =
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException:
Server was unable to process request.
---> System.Data.SqlClient.SqlException:
Procedure or function 'getWCity' expects parameter '@CountryName',
which was not supplied.
at WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName)
--- End of inner exception stack trace ---
</faultstring><detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
我知道服务器正在响应。我可以像这样用 Python 和 suds 询问它:
from suds.client import Client
url = 'http://www.webservicex.net/globalweather.asmx?WSDL'
client = Client(url)
result = client.service.GetCitiesByCountry('Australia')
我的简单问题是我做错了什么?
我还想知道如何查看 createSoapMessage 创建的 DOM 对象以及如何查看 MATLAB 发送和接收的 xml。