savonrb / wasabi

A simple WSDL parser
MIT License
90 stars 84 forks source link

Wasabi::Parser.parse_endpoint double escapes endpoint urls (<soap:address location/>). #25

Closed thoughtchad closed 11 years ago

thoughtchad commented 11 years ago

3.1.0 / v2 / lib/wasabi/parser.rb

1. Snippet from WSDL with a long endpoint url that's already properly encoded.

<service name="ExecuteAnalysis">
    <port name="ExecuteAnalysisSoapHttpPort" binding="tns0:ExecuteAnalysisSoapHttp">
        <soap:address location="http://localhost/soapservice/execute?path=%2Fbase%2Fincludes%2FTest+Soap%2FReturn+Rows"/>
    </port>
</service>

2. The SOAP endpoint that request gets sent to:

I, [2013-05-08T15:19:14.606000 #3476] INFO -- : SOAP request: http://localhost/soapservice/execute?path=%252Fbase%252Fincludes%252FTest+Soap%252FReturn+Rows

3. SOAP service chokes on the %252F's

4. Trouble code below assuming that endpoint needs to be escaped.

def parse_endpoint
  if service_node = service
    endpoint = service_node.at_xpath(".//soap11:address/@location", 'soap11' => SOAP_1_1)
    endpoint ||= service_node.at_xpath(service_node, ".//soap12:address/@location", 'soap12' => SOAP_1_2)
  end
  begin
    @endpoint = URI(URI.escape(endpoint.to_s)) if endpoint
  rescue URI::InvalidURIError
    @endpoint = nil
  end
end

5. Possible fix?

@endpoint = URI(URI.escape( URI.unescape( endpoint.to_s) ) ) if endpoint

Work-around: Manually specify properly encoded endpoint after wsdl.

Savon.client do
    wsdl "http://localhost/soapservice/inspection?wsdl=true&path=%2Fbase%2Fincludes%2FTest+Soap%2FReturn+Rows"
    endpoint "http://localhost/soapservice/execute?path=%2Fbase%2Fincludes%2FTest+Soap%2FReturn+Rows"
end
rubiii commented 11 years ago

that code is getting rediculous :) i don't even think wasabi should be responsible for escaping/unescaping the url. but i will come up with a fix for this. thanks for reporting.

thoughtchad commented 11 years ago

Nice, thx rubii. I would agree on Wasabi not escaping, or possibly a switch. This works though :-)