Java – save files to SharePoint Server using jax-ws

I tried to save a file to a SharePoint Server using Jax - WS The web service call reports success, but the file is not displayed

I use this command (from WinXP) to generate java code to make jax-ws calls:

wsimport -keep -extension -Xnocompile http://hostname/sites/teamname/_vti_bin/Copy.asmx?WSDL

I get a handle to a web service that I use the following named port: copysoap port = null;

if (userName != null && password != null) {
    Copy service = new copy();
    port = service.getCopySoap();
    ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,userName);
    ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,password);
} else {
    throw new Exception("Holy Frijolé! Null userName and/or password!");
}

I invoke the web service with the following command:

port.copyIntoItems(sourceUrl,destUrlCollection,fields,"Contents of the file".getBytes(),copyIntoItemsResult,copyResultCollection)

Sourceurl and unique URL in desturlcollection are equal to "hostname / sites / teamname / Tech docs / sub folder"

The fieldinformationcollection object named fields contains only one fieldinformation The "HelloWorld. TXT" of the fieldinformation object is used as the values of displayName, internalname and value The type attribute is set to fieldtype FILE. The ID attribute is set to (Java. Util. UUID. Randomuuid()) toString().

The call to copyintoitems returns successfully; Copyintoitemsresult contains a value of 0 and a unique copyresult object. The error code set in copyresultcollection is "success" and an empty error message is displayed

When I view the technical documentation library on SharePoint, there are no files in the subfolders

Why don't you tell me what I did wrong? Do I just want to miss one step?

Update (26 February 2011)

I have changed the displayName and internalname properties of my fieldinformation object to title There is still no happiness, but a step in the right direction

After playing the URL, I got these results:

At the same time, the sourceurl is equivalent to the unique target URL. There is no protocol. I get a success response, but there is no actual document in the document library

When two URLs are identical but a "http: / /" protocol is specified, I get an unknown error, "object reference is not set as an instance of the object" As a message

The source URL is an empty string or null, and the value is not in the expected range As an error message

Update (2 March 2011)

According to Alexei levenkov's suggestion, I used Fiddler to see what happened and found this:

#   Result  Protocol    Host    URL Body    Caching Content-Type    Process Comments    Custom  
34  401 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx?WSDL 1,656       text/html   javaw:5304          
35  401 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx?WSDL 1,539       text/html   javaw:5304          
36  200 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx?WSDL 10,887  private     text/xml; charset=utf-8 javaw:5304          
37  401 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx  1,656       text/html   javaw:5304          
38  401 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx  1,539       text/html   javaw:5304          
39  200 HTTP    hostname    /sites/teamname/_vti_bin/Copy.asmx  611 private,max-age=0      text/xml; charset=utf-8 javaw:5304

It looks like a simple handshake until it gets HTTP 200 for WSDL and web service calls

So I tried not to put my user name and password in the requestcontext. I got a similar thing, just like the above WSDL request (two HTTP 401 and one HTTP 200), but the WebService call only has one HTTP 200 If I no longer use my username / password, the authentication should fail in theory

Solution

The destination URL should contain the full path of the file I'm on the method description page – http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems.aspx View the sample

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>