I'm trying to call a Web Service with SoapWithAttachments method. My client-side software is JAVA and it uses Apache CXF (v2.5.11) to generate the classes from the WSDL.
When I run it, I print the SOAP request in the log and see that the CID prefix ("cid:") for referencing the attachment is missing. There is the correct content-id of the attachment, but the prefix is missing. Finally, the server returns me a "empty attachment" error.
There is an example of the SOAP request that my software prints:
ID: 1
Address: ****
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="text/xml"; boundary="uuid:5210b5e9-ee88-4b88-9330-f95ee62bb28e"; start="<root.message#cxf.apache.org>"; start-info="text/xml"
Headers: {Accept=[*/*], SOAPAction=["****"]}
Payload: --uuid:5210b5e9-ee88-4b88-9330-f95ee62bb28e
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-ID: <root.message#cxf.apache.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
</soap:Header>
<soap:Body>
<metodo>
<documento>
<contenido href="8849d331-555b-4ab4-b90d-6ff0996cadcc#apache.org"/>
<hash>0p9oDCPlhlxNemvtT5tj6e46SHdPWLOxTi1sLJBeCz4=</hash>
</documento>
</metodo>
</soap:Body>
</soap:Envelope>
--uuid:5210b5e9-ee88-4b88-9330-f95ee62bb28e
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <8849d331-555b-4ab4-b90d-6ff0996cadcc#apache.org>
%PDF-1.4
%????
2 0 obj
<</Length 76/Filter/FlateDecode>>stream
x?+?r
?26S?00I?2P?5?1??
?B?4<Rsr???rR
?JS?
#?]C????
endstream
endobj
4 0 obj
<</Parent 3 0 R/Contents 2 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 1 0 R>>>>/MediaBox[0 0 595 842]>>
endobj
1 0 obj
<</BaseFont/Helvetica/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1>>
endobj
3 0 obj
<</ITXT(2.1.7)/Type/Pages/Count 1/Kids[4 0 R]>>
endobj
5 0 obj
<</Type/Catalog/Pages 3 0 R>>
endobj
6 0 obj
<</Producer(iText 2.1.7 by 1T3XT)/ModDate(D:20150327140035+01'00')/CreationDate(D:20150327140035+01'00')>>
endobj
xref
0 7
0000000000 65535 f
0000000314 00000 n
0000000015 00000 n
0000000402 00000 n
0000000157 00000 n
0000000465 00000 n
0000000510 00000 n
trailer
<</Root 5 0 R/ID [<5d256b5d87f178862dd33943e65718e8><ecd829bf4e1d355aef68138d0de19d76>]/Info 6 0 R/Size 7>>
startxref
632
%%EOF
--uuid:5210b5e9-ee88-4b88-9330-f95ee62bb28e--
Notice that the attachment does exist, and it has a correct Content-id (I supose), and the SOAP request references it in a apparently correct name. But the "cid:" prefix is still missing and I don`t have idea how to add it.
On the other hand, if I copy and paste the SOAP request from here to SOAP-UI, and add the "cid:" prefix, and add the attachment with the same Content-id, the request runs correctly.
Related
I want to display a user's activity feed in an rails application. I am using feedjira.
2.2.4 :006 > xml_feed = Feedjira::Feed.fetch_raw "https://github.com/prasadsurase.atom"
2.2.4 :006 > github_feed = Feedjira::Feed.parse xml_feed
2.2.4 :006 > github_feed.entries.first.content
=> "<!-- pull_request -->\n<svg aria-label=\"Pull request\" class=\"octicon octicon-git-pull-request dashboard-event-icon\" height=\"32\" role=\"img\" version=\"1.1\" viewBox=\"0 0 12 16\" width=\"24\"><path d=\"M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z\"></path></svg>\n\n<div class=\"time\">\n <relative-time datetime=\"2016-09-23T07:30:24Z\">Sep 23, 2016</relative-time>\n</div>\n\n<div class=\"title\">\n prasadsurase opened pull request joshsoftware/code-curiosity#136\n</div>\n\n<div class=\"details\">\n <img alt=\"#prasadsurase\" class=\"gravatar\" height=\"30\" src=\"https://avatars3.githubusercontent.com/u/562052?v=3&s=60\" width=\"30\" />\n <div class=\"message\">\n <blockquote>Fixed controller method scopes. Removed unwanted routes.</blockquote>\n <div class=\"pull-info\">\n <svg aria-hidden=\"true\" class=\"octicon octicon-git-commit\" height=\"16\" version=\"1.1\" viewBox=\"0 0 14 16\" width=\"14\"><path d=\"M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z\"></path></svg>\n <em>1</em> commit with\n <em>34</em> additions and\n <em>31</em> deletions\n </div>\n </div>\n</div>\n"
when rendering the content for every entry from github_feed.entries in haml as raw, the links do not contain the domain https://github.com/ but contain only the path. This causes problem as such that the rendered links on the UI contain the app domain and not github. How do we fix this?
Since github atom feeds provides the content with relative url's you might want to replace them with absolute references.
This could be done with
gsub( %r{<a href=\"/},'<a href="https://github.com/')
And thus replace your:
2.2.4 :006 > github_feed.entries.first.content
with
2.2.4 :006 > github_feed.entries.first.content.gsub( %r{<a href=\"/},'<a href="https://github.com/')
=> "<!-- pull_request_review_comment -->\n<svg aria-label=\"Review pull request comment\" class=\"octicon octicon-comment-discussion dashboard-event-icon\" height=\"32\" role=\"img\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"32\"><path d=\"M15 1H6c-.55 0-1 .45-1 1v2H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h1v3l3-3h4c.55 0 1-.45 1-1V9h1l3 3V9h1c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM9 11H4.5L3 12.5V11H1V5h4v3c0 .55.45 1 1 1h3v2zm6-3h-2v1.5L11.5 8H6V2h9v6z\"></path></svg>\n\n<div class=\"time\">\n <relative-time datetime=\"2016-09-28T03:21:31Z\">Sep 28, 2016</relative-time>\n</div>\n\n<div class=\"title\">\n prasadsurase commented on pull request joshsoftware/code-curiosity#137\n</div>\n\n<div class=\"details\">\n <img alt=\"#prasadsurase\" class=\"gravatar\" height=\"30\" src=\"https://avatars3.githubusercontent.com/u/562052?v=3&s=60\" width=\"30\" />\n <div class=\"message markdown-body\">\n <blockquote>\n <p>#BandanaPandey Same here.</p>\n </blockquote>\n </div>\n</div>\n"
I wish to output debugging logging for JAXRS like this (as per documentation)...
3 X-Jersey-Tracing-000: START [ ---- / ---- ms | ---- %] baseUri=[http://localhost:9998/ALL/] requestUri=[http://localhost:9998/ALL/root/sub-resource-locator/sub-resource-method] method=[POST] authScheme=[n/a] accept=[application/x-jersey-test] accept-encoding=n/a accept-charset=n/a accept-language=n/a content-type=[application/x-jersey-test] content-length=[11]
4 X-Jersey-Tracing-001: PRE-MATCH [ 0.01 / 0.68 ms | 0.01 %] PreMatchRequest summary: 2 filters
5 X-Jersey-Tracing-002: MATCH [ 8.44 / 9.15 ms | 4.59 %] RequestMatching summary
6 X-Jersey-Tracing-003: REQ-FILTER [ 0.01 / 9.20 ms | 0.00 %] Request summary: 2 filters
7 X-Jersey-Tracing-004: RI [86.14 / 95.49 ms | 46.87 %] ReadFrom summary: 3 interceptors
8 X-Jersey-Tracing-005: INVOKE [ 0.04 / 95.70 ms | 0.02 %] Resource [org.glassfish.jersey.tests.integration.tracing.SubResource #901a4f3] method=[public org.glassfish.jersey.tests.integration.tracing.Message org.glassfish.jersey.tests.integration.tracing.SubResource.postSub(org.glassfish.jersey.tests.integration.tracing.Message)]
9 X-Jersey-Tracing-006: RESP-FILTER [ 0.01 / 96.55 ms | 0.00 %] Response summary: 2 filters
10 X-Jersey-Tracing-007: WI [85.95 / 183.69 ms | 46.77 %] WriteTo summary: 4 interceptors
11 X-Jersey-Tracing-008: FINISHED [ ---- / 183.79 ms | ---- %] Response status: 200/SUCCESSFUL|OK
But all I can achieve is this...
03-Feb-2016 13:18:17.027 INFO [http-nio-8084-exec-270] org.glassfish.jersey.filter.LoggingFilter.log 3 * Server has received a request on thread http-nio-8084-exec-270
3 > GET http://localhost:8084/SocialScheduler/rest/dostuff?startDate=03%2F02%2F2016%2013%3A17&endDate=04%2F02%2F2016%2013%3A17&resolutionMins=720&_=1454505462184
3 > accept: application/json, text/javascript, */*; q=0.01
3 > accept-encoding: gzip, deflate, sdch
3 > accept-language: en-US,en;q=0.8
3 > connection: keep-alive
3 > cookie: JSESSIONID=7BDAEC5068C7A8F6FE26263EBF6998CE; cookieconsent_dismissed=yes; cookie_assistant_enable_cookies=true; __uvt=; _ga=GA1.1.1324172961.1446064949; _gat=1; __smToken=6obzPmlxzCuYugw7AHhVSuH7; linkedin_oauth_773fp8xagqy7nf_crc=null; uvts=3jj9UU7vonmXljiC
3 > host: localhost:8084
3 > referer: http://localhost:8084/projectx/app.jsp
3 > user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36
3 > x-requested-with: XMLHttpRequest
03-Feb-2016 13:18:17.080 INFO [http-nio-8084-exec-270] org.glassfish.jersey.filter.LoggingFilter.log 3 * Server responded with a response on thread http-nio-8084-exec-270
3 < 200
3 < Content-Type: application/json
The latter is useful, but it doesn't show me the chain of events, i.e. START, PRE-MATCH, MATCH, REQ-FILTER, RI, INVOKE, RESP-FILTER, WI, FINISHED.
Under Amazon Web Services (AWS) my AJAX requests seem to freeze after around 12 hours (not always exactly the same time), so I'd like to see more than the HTTP header; how far am I getting in the chain / where is it getting stuck?!
Here's the code I currently have...
package uk.co.devology.projectx;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
#ApplicationPath("/rest/*")
public class RestResourceConfig extends ResourceConfig {
public RestResourceConfig() {
packages("uk.co.devology.projectx");
register(new LoggingFilter());
// property(ServerProperties.TRACING, "ALL");
// property(ServerProperties.TRACING_THRESHOLD, "SUMMARY");
property("jersey.config.server.tracing", "ALL");
property("jersey.config.server.tracing.threshold", "VERBOSE");
}
}
It would seem that all of the logging is being performed by the line
register(new LoggingFilter());
And that the following lines don't appear to do anything
property("jersey.config.server.tracing", "ALL");
property("jersey.config.server.tracing.threshold", "VERBOSE");
There's no web.xml file, it's using Servlet 3 spec and JAXRS combined to discover the restful endpoints.
In older versions of JAXRS this seemed simpler.
I should point out that I am using Log4J with this configuration and I'm starting to wonder whether I need to do something with the Java Logger / Bridge instead?
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%p %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
I have tried changing the Root level to 'trace' too.
So what you're trying to use is the LoggingFilter to see the response headers, but it doesn't look like the headers are added yet by the time the LoggingFilter is called. The headers do show up in the actual response headers though. You need to check with your client to see them.
As far as logging on the server, it appears the logging level needs to be set to FINER to see all the logging. I've tested and this seems to be the case. All the logs are coming out as FINER. To set only the tracing logging level to FINER, you can add this to you logging properties file
org.glassfish.jersey.tracing.level=FINER
Note this is Java Util Logging. There are a bunch of tutorials out there, if you are not sure how to use and configure this logging framework.
I am trying to download 1000s of files which may be very large (several GB) from an HTTP site using PycURL.
Everything was going swimmingly until I decided to check for partial downloads, so tried to use info I found on this forum to try to get the Content-Length. Once I realised it was always returning 179.0, I looked into the response and found that 179.0 seems to be the length of the "Why didn't you check first that what you are doing is supported?" response.
>>> c.setopt(c.RANGE, "NULL")
>>> c.setopt(c.HEADER,1)
>>> c.setopt(c.NOBODY,1)
>>> c.perform()
HTTP/1.1 501 Not Implemented
Date: Fri, 14 Aug 2015 02:00:35 GMT
Server: Apache-Coyote/1.1
Pragma: no-cache
DataServiceVersion: 1.0
Content-Type: application/xml
Content-Length: 179
Second attempt to get the size, I tried using RANGE. Range works on the server but running the suggested 0-0 seems to be extremely slow.
>>> c.setopt(c.RANGE, "0-0")
>>> c.setopt(c.HEADER,1)
>>> c.setopt(c.NOBODY,0)
>>> c.perform()
HTTP/1.1 206 Partial Content
Date: Fri, 14 Aug 2015 02:05:15 GMT
Server: Apache-Coyote/1.1
Pragma: no-cache
Accept-Ranges: bytes
Content-Disposition: inline; filename="foo.zip"
Content-Range: bytes 0-0/2278939680
I don't need to stick with PycURL to find the size but I do need speed.
N.B. I'm using Python 2.7
My Jmeter response returns me 'Location' in the response header.I want to fetch this Location header and use it on my other requests.
Sample Start: 2015-07-24 14:46:38 CEST
Load time: 163
Latency: 163
Size in bytes: 372
Headers size in bytes: 350
Body size in bytes: 22
Sample Count: 1
Error Count: 1
Response code: 201
Response message: Processed
Response headers:
HTTP/1.1 201 Processed
X-Backside-Transport: OK OK,FAIL FAIL
Connection: Keep-Alive
Transfer-Encoding: chunked
****Location: /retail/iows/ie/en/storage/servicedocs/paxplanner/2015-07-24/eCommerce.pdf****
X-Client-IP: 127.0.0.1,10.62.26.150
Content-Type: application/octet-stream
Date: Fri, 24 Jul 2015 12:46:38 GMT
X-Archived-Client-IP: 127.0.0.1
Steps I followed:
I have used Regular expression extractor.
Enabled response header radio button with the whole location header.
Please help me to sort it out.
If you want to retrieve the Location field's value from the request's response, you might want to try the following pattern: Location:([^\r?\n]+), the first matching group will contain the value of the Location field.
Above expression is based in the following rules:
HTTP header fields are colon (":") separated <key, value> pairs.
HTTP header fields are terminated by the EOL char combination (CR and LF)
Please try this..
Location:([\s\S]*)X-Client
If it doesn't work then try to use a \ before - in X-Client (escaping -)
I have been working for the last couple of days trying to get a file upload to my drupal REST Server and I feel like I am close but I am getting a somewhat confusing 200 status code with a response of "false". I am a total http-request novice so I have been having some trouble. Here is what my http-post looks like:
POST /?q=rest/file HTTP/1.1
Host: localhost:8888
Language: en-us,en;q=0.5Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Accept-Charset: ISO-8859-1,utf-8
Cookie: SESSdc0685ed01f285dab628a3700259e6bc=UAdNJUsQL5TpqEXIWFtXEcLw3wooEwqW9e0JxSz2ZHw
Content-Length: 389
Content-Type: multipart/form-data; boundary=---------------------------1137522503144128232716531729
-----------------------------1137522503144128232716531729
Content-Disposition: form-data; name=\"file\"; filename=\"empty folder.zip\"
Content-Type: application/zip
..
encoded content here
..
-----------------------------1137522503144128232716531729--
And the response I get is simply "false with a header that looks like this:
(("Content-Type" "application/json") ("Connection" "Keep-Alive") ("Keep-Alive" "timeout=5, max=100") ("Content-Length" "5") ("Vary" "Accept") ("ETag" "\"1328910809\"") ("Cache-Control" "no-cache, must-revalidate, post-check=0, pre-check=0") ("Last-Modified" "Fri, 10 Feb 2012 21:53:29 +0000") ("Expires" "Sun, 19 Nov 1978 05:00:00 GMT") ("X-Powered-By" "PHP/5.3.6") ("Server" "Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6") ("Date" "Fri, 10 Feb 2012 21:53:29 GMT") ("Status" "HTTP/1.1 200 OK"))
and status code 200. Also, the file is does not actually show up in the Drupal file system. Could the problem be that I need to specify where to put it? I snooped the http-post from the actual Drupal form and it looks almost identical to my post accept it has many more pieces of content.