I'm working on syncing files with 4shared.com over the WEBDAV protocol. I need to attach a dead property to it when adding a file. To do this, I use the PROPPATCH method. Server response <D:status>HTTP/1.1 404</D:status>. A similar approach works on other servers.
Please tell me how I can add a dead property to a file?
Request:
<?xml version="1.0" encoding="utf-8"?> <D:propertyupdate xmlns:D="DAV:" xmlns:U="tsov.pro"> <D:set> <D:prop> <U:MYUID>b303e2f5-21ab-4e5f-9c8c-806bd3935189</U:MYUID> </D:prop> </D:set> </D:propertyupdate>
Answer:
<?xml version="1.0" encoding="utf-8" ?> <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>/00-00014760/myfile.png</D:href> <D:propstat> <D:prop> <MYUID/> </D:prop> <D:status>HTTP/1.1 404</D:status> </D:propstat> </D:response> </D:multistatus>
Sincerely, Mikhail.
Related
I am using Wiremock (which appears to use jetty) to stub some http responses.
I am sending a multipart http request but Wiremock/jetty responds to with a 500 error and some html which details a MalformedStreamException.
This has only broken since a version upgrade of Wiremock from 2.31.0 to 2.32.0.
I am sending the following request in Postman to my stub endpoint:
Headers
Content-Type: multipart/related; boundary=xxx
Request body
--xxx
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" encoding="utf-8"?>
<test></test>
--xxx
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" encoding="utf-8"?>
<test></test>
--xxx--
Error
Caused by: wiremock.org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
at wiremock.org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:361)
at com.github.tomakehurst.wiremock.http.multipart.PartParser.parseFrom(PartParser.java:51)
at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.getParts(WireMockHttpServletRequestAdapter.java:286)
at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:71)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:88)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:226)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:57)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:69)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:142)
at wiremock.javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at wiremock.org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1631)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at wiremock.org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
... 17 more
Caused by: wiremock.org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
at wiremock.org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:570)
at wiremock.org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1052)
at wiremock.org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:1017)
at wiremock.org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:309)
at wiremock.org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:333)
... 38 more
Can anyone spot anything I am doing wrong or have any suggestions of things to rule out or try?
Could there be a bug in Wiremock or one of its dependences or is my multipart request malformed?
Update
I've opened a bug on Github:
https://github.com/wiremock/wiremock/issues/1973
We have the following combination in our application.
Spring mvc + tiles as view resolver + controller mapping (Request mapping)
Docker to run our application
Splunk to check the logs (developers dont have access to login to the server and check the logs)
We are trying to hit the following URL in Production which gives 404 in the network tab but it works fine in all other envs (there was one request which was successful in production using the same URL). All other URLs are working fine in production.
https://host:port/context_name/assignUpdate.do
Here is the code for the same.
web.xml
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
dispatcher-servlet.xml
<mvc:default-servlet-handler />
<context:annotation-config />
<aop:aspectj-autoproxy />
<context:component-scan base-package="we have correct package mentioned here" />
SomeController.java
#Controller
public class SomeController {
#RequestMapping(value = "assignUpdate", method = RequestMethod.POST)
public ModelAndView assignCampaignUpdate(formparam form, HttpSession session){
method body
}
}
Points to be considered
How about adding #ModelAttribute before formparam (not sure that will make any difference)
formparam has a member var which is a List of some other class which has all primitives (the volume of some other class goes huge around 1.2K in production whereas in the other envs it will be around 50) - also tried this one by bringing down the search to one item in UI and sent the request. din work
Any help here
Request Headers
Accept: /
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 993
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Only log which i could get
[logtype=access] x_client_ip="ip" date="[09/Aug/2018:07:27:09 -0400]" http_status="404" content_length=0 referer="https://localhost:port/context_name/mainpage.do" user_agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" method=POST uri="/context_name/assignUpdate.do" query="" protocol=HTTP/1.1 durationms=55 fsreqid=- srcip=10.42.247.20
After spinning my head for long time, i finally got the solution for the above problem.
The exception was IndexoutofBounds. In the request body, we are passing object with index more than 256. Since spring framework supports collection limit of 0 - 255 as index in the request body object, dispatcher servlet throws indexoutofbounds exception and returns 404 as status code for that request. To overcome this issue, we need to override the default collection limit of 256 which is provided by spring framework.
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
#InitBinder
public void initBinder(WebDataBinder dataBinder) {
dataBinder.setAutoGrowCollectionLimit(600);
}
For more information, refer https://dzone.com/articles/spring-initbinder-for-handling-large-list-of-java
Contacts synchronization at least with davdroid client doesn’t work well.
This is what I found in IT Hit WebDAV Server log:
[11] ----------------- Started: 24.11.2015 15:00:12 -----------------
[11] [REPORT] /addressbooks/webdavuser/Business/
Connection: Keep-Alive
Content-Length: 184
Content-Type: application/xml; charset=utf-8
Accept-Encoding: gzip
Authorization: Basic ************************
Host: devel.jablotool.com:50001
User-Agent: DAVdroid/0.9.1.1 (2015/11/24; dav4android) Android/4.2.2
Depth: 1
[11] <?xml version='1.0' encoding='UTF-8' ?><CARD:addressbook-query xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav"><prop><getetag /></prop><CARD:filter /></CARD:addressbook-query>
[11] HTTP/1.1 405 Method Not Allowed
X-Env-Version : 4.0.30319.34209 64bit
X-OS-Version : Microsoft Windows NT 6.1.7601 Service Pack 1
X-IIS-Version : Microsoft-IIS/7.5
X-Worker-Request : System.Web.Hosting.IIS7WorkerRequest
Access-Control-Allow-Origin : *
Access-Control-Allow-Credentials : true
Access-Control-Allow-Methods : ACL, CANCELUPLOAD, COPY, DELETE, GET, HEAD, CHECKIN, CHECKOUT, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL
Access-Control-Allow-Headers : Overwrite, Destination, Content-Type, Depth, User-Agent, Translate, Range, Content-Range, Timeout, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Location, Lock-Token, If
Access-Control-Expose-Headers : DAV, content-length, Allow
Access-Control-Max-Age : 2147483647
X-Engine : IT Hit WebDAV Server .Net v4.0.2416.0 (Evaluation License)
Content-Type : application/xml; charset=utf-8
[11] <?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:">
<d:responsedescription>The report is not supported.</d:responsedescription>
</d:error>
[11] ----------------- Finished: 24.11.2015 15:00:12 Took 0ms --------
Accoding to the RFC-6352 CARDDAV:addressbook-query REPORT support is required. IT Hit WebDAV Server implementation of CardDAV server returs http status code 405. Is it problem of the client or server implementation of the CardDAV protocol?
This is the answer I got directly from ItHit:
Just a quick update regarding addressbook-query support. I was wrong about its
support. Our engine currently supports calendar-query, calendar-multiget and addressbook-multiget, but not addressbook-query. We are working to add its support in the next update.
According to RFC implementation of addressbook-query is required. WebDAVServerEngine version 4.0.2416 is not full implementation of CardDAV protocol.
i have a web service its run locally, but when i hosted on AWS its not running from my client I get the error "System.ServiceModel.ProtocolException: There is a problem with the XML ..."
I tried to call it from SoapUI its working
this is the request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:her="http://HerakiNet.com/">
<soapenv:Header/>
<soapenv:Body>
<her:SayHello>
<!--Optional:-->
<her:name>Ahmed</her:name>
</her:SayHello>
</soapenv:Body>
</soapenv:Envelope>
and the response as raw:
HTTP/1.0 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Date: Sun, 29 Dec 2013 11:12:39 GMT
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 359
X-Cache: MISS from UB15-WMJ-080811
Via: 1.1 UB15-WMJ-080811:3128 (Lusca)
Connection: keep-alive
<?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><SayHelloResponse xmlns="http://HerakiNet.com/"><SayHelloResult>Hello , Ahmed</SayHelloResult></SayHelloResponse></soap:Body></soap:Envelope>
can any one help??
this is the result of executing a small test from DotNet App:
System.ServiceModel.ProtocolException: There is a problem with the XML that was
received from the network. See inner exception for more details. ---> System.Xml
.XmlException: The data at the root level is invalid. Line 1, position 1 ...
the application code is:
var client = new EstimatorWcfService.EstimatorWebServiceSoapClient();
Console.WriteLine(client.SayHello("Ahmed"));
According to error, you are calling wrong end point url from your client.
There would be two urls in service tag in your wsdl one for http and another for https. May be you are using https one instead of http. Cross check from soap ui (at top of your request).
tl;dr
Do you need to implement the Microsoft WebDav Extension Properties to properly work with Word.
Extended Question
I'm building out a WebDav server ontop of the pre-existing WebDAV.NET open source project. I noticed that with Word 2010 (didn't try other versions) their sample code doesn't correctly handle saving Microsoft Word documents as it will say "Upload failed" even though the document saves correctly and you are the only user of the file. I'm trying to track down the reason why, and one thing that caught my eye was the Microsoft WebDav Extension Properties. The MS page for this states that "A WebDAV server implementing WebDAV Protocol: Microsoft Extensions SHOULD implement the following extended properties." Since it states should, I would assume you do not have to support it to work with Word.
I became suspicious of the extensions when I noted that my propfind request/response looks like the following:
PROPFIND /test123.docx HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: no-cache
Content-Type: text/xml; charset="utf-8"
User-Agent: Microsoft Office Core Storage Infrastructure/1.0
Depth: 0
Translate: f
Connection: Keep-Alive
Content-Length: 208
Host: localhost:62954
<?xml version="1.0" encoding="utf-8" ?><D:propfind xmlns:D="DAV:" xmlns:Office="urn:schemas-microsoft-com:office:office"><D:prop><D:creationdate/><D:getlastmodified/><Office:modifiedby/></D:prop></D:propfind>
HTTP/1.1 207 Multi-Status
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 16 Apr 2012 14:11:55 GMT
X-AspNet-Version: 4.0.30319
MS-Author-Via: DAV
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Content-Length: 576
Connection: Close
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response>
<D:href>http://localhost:62954/test123.docx</D:href>
<D:propstat>
<D:prop>
<D:creationdate>2012-04-10T08:00:00Z</D:creationdate>
<D:getlastmodified>2012-04-16T09:09:44Z</D:getlastmodified>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
<D:propstat>
<D:status>HTTP/1.1 404 Not Found</D:status>
<D:prop>
<modifiedby xmlns="urn:schemas-microsoft-com:office:office" />
</D:prop>
</D:propstat>
</D:response>
</D:multistatus>
In case anyone is curious, the following is my PUT response.
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 16 Apr 2012 14:18:06 GMT
X-AspNet-Version: 4.0.30319
MS-Author-Via: DAV
Cache-Control: private
Content-Length: 0
Connection: Close
By the way, I found the bug in Sphorium webdav that was causing this. The bug was in the method DavLockBase_InternalProcessDavRequest() and the incorrect line of code was:
string[] _lockTokens = this.RequestLock.GetLockTokens();
which should be:
string[] _lockTokens = this.ResponseLock.GetLockTokens();
No, you don't need to implement the Microsoft WebDAV Extension Properties.
(I figured out the answer to my own question)
The issue with WebDAV.NET is that there is a bug in it that an empty LockToken in the header which confuses Word and makes it not give the LockToken to the PUT request.