#ruby #savon
#ruby #savon
Вопрос:
Я использую savon 0.9.7 и ruby 1.8.7, я делаю этот запрос:
client = Savon::Client.new do
wsdl.document = "http://localhost:3000/wsdl/service.asmx?WSDL"
end
response = client.request "Body3DGeneration" do
soap.body = {
:path => 'adsa',
:measures => 'assaasd',
:landmarks => 'adsd'
}
http.headers["SOAPAction"] = "http://xx.xx.xx.xx/services/1"
end
Savon отправляет это сообщение:
SOAPAction: http://xx.xx.xx.xx/services/1,
Content-Type: text/xml;charset=UTF-8,
Content-Length: 526
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="http://xx.xx.xx.xx/services" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="http://xx.xx.xx.xx/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<ins0:Body3DGeneration>
<ins0:path>adsa</ins0:path>
<ins0:measures>assaasd</ins0:measures>
<ins0:landmarks>adsd</ins0:landmarks>
</ins0:Body3DGeneration>
</env:Body>
</env:Envelope>
Но сервер требует чего-то подобного:
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://xx.xx.xx.xx/services/1"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Body3DGeneration xmlns="http://xx.xx.xx.xx/services">
<path>string</path>
<landmarks>string</landmarks>
<measures>string</measures>
</Body3DGeneration>
</soap:Body>
</soap:Envelope>
Я получаю следующую ошибку:
SOAP response (status 500):
<?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>Server was unable to process request. ---amp;> Data at the root level is invalid. Line 1, position 1.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Savon::SOAP::Fault: (soap:Server) Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1.
Вы можете мне помочь? Я думаю, что я не выполняю хороший запрос savon, но я ничего не нахожу в документации.
Комментарии:
1. Извините, ребята, эта ошибка является ответом сервера, параметры неверны!
Ответ №1:
вы можете проверить сервер, используя пример необработанного запроса
response = client.request do |soap|
soap.xml = '<?xml version="1.0" encoding="UTF-8"?>....'
http.headers["SOAPAction"] = "http://xx.xx.xx.xx/services/1"
end