Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Headers in HTTPI Body Doc #682

Closed
toobulkeh opened this issue Apr 22, 2015 · 10 comments
Closed

HTTP Headers in HTTPI Body Doc #682

toobulkeh opened this issue Apr 22, 2015 · 10 comments

Comments

@toobulkeh
Copy link

[33] pry(main)> response.http
=> #<HTTPI::Response:0x000000072981a8
 @body=
  "\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d\r\nContent-Type: application/xop+xml; charset=UTF-8; type=\"text/xml\";\r\nContent-Transfer-Encoding: binary\r\nContent-ID: <root.message@cxf.apache.org>\r\n\r\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:createLocalPIDResponse xmlns:ns2=\"http://remoting.ws.ehr.spirit.com/\"><return><dataMap/><stateID>e1e6aa1b7f0000011975d9e868e8b378</stateID><responseDetail/><responseData><domain><authUniversalID>2.16.840.1.113883.3.704.100.300.1.1.3.1</authUniversalID><authUniversalIDType>ISO</authUniversalIDType></domain><ehrPIDType>134</ehrPIDType><patientID>TST.14297192868322</patientID><patientIDType>PI</patientIDType></responseData></return></ns2:createLocalPIDResponse></soap:Body></soap:Envelope>\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d--",
 @code=200,
 @headers=
  {"server"=>"Apache-Coyote/1.1",
   "content-type"=>
    "multipart/related; type=\"application/xop+xml\"; boundary=\"uuid:51d686cd-1f98-44db-b0f7-84506459ce9d\"; start=\"<root.message@cxf.apache.org>\"; start-info=\"text/xml\"",
   "content-length"=>"818",
   "date"=>"Wed, 22 Apr 2015 16:14:46 GMT"},
 @raw_body=
  "\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d\r\nContent-Type: application/xop+xml; charset=UTF-8; type=\"text/xml\";\r\nContent-Transfer-Encoding: binary\r\nContent-ID: <root.message@cxf.apache.org>\r\n\r\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:createLocalPIDResponse xmlns:ns2=\"http://remoting.ws.ehr.spirit.com/\"><return><dataMap/><stateID>e1e6aa1b7f0000011975d9e868e8b378</stateID><responseDetail/><responseData><domain><authUniversalID>2.16.840.1.113883.3.704.100.300.1.1.3.1</authUniversalID><authUniversalIDType>ISO</authUniversalIDType></domain><ehrPIDType>134</ehrPIDType><patientID>TST.14297192868322</patientID><patientIDType>PI</patientIDType></responseData></return></ns2:createLocalPIDResponse></soap:Body></soap:Envelope>\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d--">

Any ideas why the response.http.body contains apache header information even though that's parsed out correctly? The following shouldn't be in the body or raw_body:

"\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d\r\nContent-Type: application/xop+xml; charset=UTF-8; type=\"text/xml\";\r\nContent-Transfer-Encoding: binary\r\nContent-ID: <root.message@cxf.apache.org>\r\n\r\n"
@tjarratt
Copy link
Contributor

Thanks for opening this issue @toobulkeh -- it looks like your response is a multipart response, so you might want to try using Savon Multipart to parse those. Simply adding that to your Gemfile and require 'savon-multipart' should be enough.

I've been considering bringing Savon::Multipart directly into core for a while. It seems like a pretty crummy user experience to have to bring in a separate gem whenever you need to parse multipart SOAP responses. Would you let me know if that solves your problem? If not, maybe I can direct you towards the code in Savon that is responsible for parsing the header and body.

@toobulkeh
Copy link
Author

Thanks for the help @tjarratt -- I'm not familiar with multipart responses (or attachments) in SOAP, so that's a great pointer. I'll give it a shot and update this if I need additional help!

From the perspective of a newbie to both gems, I would definitely merge them, as it doesn't seem like the functionality needs to be separate (from my perspective). The versioning was a little complex to get setup as well, since the multipart gem is locked to a specific savon version.

Hope this helps!

@toobulkeh
Copy link
Author

Unfortunately that didn't solve my problem, as I'm still receiving:

from /usr/local/rvm/gems/ruby-2.2.1/gems/savon-2.10.1/lib/savon/response.rb:90:in 'raise_invalid_response_error!'

I'll continue to troubleshoot it, thanks!

@toobulkeh
Copy link
Author

Is there a way to force the response to savon-multipart? After researching this more, that's what is happening here... The response is only a normal Savon::Response and doesn't have the multipart functions... even if that's the only gem 'required'...

@toobulkeh
Copy link
Author

pulling from https://github.com/savonrb/savon-multipart/blob/master/spec/savon/soap/response_spec.rb#L9

I created this that forced the response into a multipart class, which worked.

globals = {
      :multipart => true,
      :raise_errors => true,
      :convert_response_tags_to  => lambda { |tag| tag.snakecase.to_sym}
 }

response = Savon::Multipart::Response.new(response.http, globals, {})
response.hash

Any ideas why this doesn't happen automatically, or if I'm missing something?

Thanks!

@tjarratt
Copy link
Contributor

Good question. The multipart detection is probably incomplete. We had a good pull request recently that improved it a bit, but I haven't got around to publishing a new version of the gem yet.

It sounds like there's still a bug here, so I'd like to reopen this bug. Would it be possible for you to attach an anonymized response, so I can take a look at the Content-Type header and try to infer why savon-multipart wasn't able to detect the content type correctly?

Sent From A Very Small Keyboard

On Apr 27, 2015, at 19:56, Dan Moore notifications@github.com wrote:

Closed #682.


Reply to this email directly or view it on GitHub.

@toobulkeh
Copy link
Author

let me test it against the current master, then I'll look into submitting a PR if it doesn't work :)

@toobulkeh toobulkeh reopened this Apr 28, 2015
@toobulkeh
Copy link
Author

Can you move the issue to the other github repo?

@tjarratt
Copy link
Contributor

Migrated this issue over to Savon-Multipart.

@alexmonteiro
Copy link

I'm in the same issue in 2017. I need to get some information of legacy systems using WS, and the response comes with extra content like "\r\n--uuid:51d686cd-1f98-44db-b0f7-84506459ce9d\r\nContent-Type: application/xop+xml;"

By the way I'm using the @toobulkeh forced solution to create a Savon::Multipart::Response that gives a clean soap message, but I would be gladfull if Savon or Multipart already did it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants