0
 http = Net::HTTP.new('rty.makemytrip.com', 80)
   http.use_ssl = false
   path="http://rty.makemytrip.com/btd_Webs_CreateIncident/MMT_Webs_CreateIncident.asmx?op=CreateIncident"
# Create the SOAP Envelope
data = <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP:Body>
    <CreateIncident xmlns="http://MakeMyTrip.org/">
      <FirstName>#{params[:name]}</FirstName>
      <Email>#{params[:email]}</Email>
      <CityOfResidence>#{params[:city]}</CityOfResidence>
      <MobilePhone>#{params[:mobile]}</MobilePhone>
    </CreateIncident>
  </SOAP:Body>
</SOAP-ENV:Envelope>
EOF
# Set Headers
headers = {
  'Content-Type' => 'Content-Type: application/soap+xml; charset=utf-8'
}
# Post the request
resp, data = http.post(path, data, headers)
# Output the results
logger.error "code  = >>>>>>>>#{resp.code}"
logger.error "Response message = >>>>>>>>Message =#{resp.message}"
resp.each { |key, val|
  logger.error  "key>#{key}>>>>>#{val}"
}
logger.error "data>>>>>#{ data}"

このエラーが発生します

code  = >>>>>>>>500
Response message = >>>>>>>>Message =Internal Server Error
key>x-powered-by>>>>>ASP.NET
key>x-aspnet-version>>>>>2.0.50727
key>connection>>>>>close
key>content-type>>>>>text/xml; charset=utf-8
key>date>>>>>Thu, 19 Sep 2013 08:35:13 GMT
key>server>>>>>Microsoft-IIS/7.5
key>content-length>>>>>442
key>cache-control>>>>>private
data>>>>>
   <?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. ---&gt; 'SOAP' is an undeclared namespace. Line 8, position 5.</faultstring>
         <detail />
       </soap:Fault>
     </soap:Body>
   </soap:Envelope>

このコードの何が問題なのですか

4

1 に答える 1

1

エラーは、名前空間が宣言されていないため、リクエストの'SOAP' is an undeclared namespace. Line 8, position 5.この文字列に文句を言います。<SOAP:Body>SOAP

したがって、SOAP-ENV名前空間として宣言したためhttp://schemas.xmlsoap.org/soap/envelope/、に変更する必要があると思います<SOAP-ENV:Body></SOAP:Body>に変更することも忘れないでください</SOAP-ENV:Body>

于 2013-09-19T08:46:08.113 に答える