I have a small app which query our SharePoint server’ Web Service interface for a list of all users for a group.
I can see the raw HTTP response is coming back with all the users listed, but JAX-WS response object (as created under NetBeans 6.9) contains only a blank Group Name String value. There is no trace of all the user names from the HTTP response.
Anyone know why JAX-WS is not reading in the SOAP response correctly?
The WSDL is to long to post, but is widely accessable from various locations, including this site:
http://www.hezser.de/_vti_bin/UserGroup.asmx?wsdl
Here’s the start of raw HTTP response:
---[HTTP response - http://{server}/_vti_bin/usergroup.asmx - 200]---
null: HTTP/1.1 200 OK
Cache-control: private, max-age=0
Content-type: text/xml; charset=utf-8
Content-length: 136738
X-powered-by: ASP.NET
Server: Microsoft-IIS/6.0
Date: Wed, 22 Sep 2010 20:53:12 GMT
X-aspnet-version: 2.0.50727
Set-cookie: WSS_KeepSessionAuthenticated=80; path=/
Microsoftsharepointteamservices: 12.0.0.6303
<?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><GetUserCollectionFromGroupResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"><GetUserCollectionFromGroupResult><GetUserCollectionFromGroup><Users><User ID="201" Sid="S-1-5-21-1545385408-2720673749-3828181483-1245" ....
You’ll need to edit the UserGroup.wsdl manually before generating the stubs. You need to add
processContents='skip'to the<s:any>tag where the response is defined.Then, when processing the response, JAXB will return the children as DOM Elements:
Why this works
The problem is caused by a combination of conditions:
A. The response returned by the web service contains a
<GetUserCollectionFromGroup>tag:B. The schema embedded in the WSDL defines the
<GetUserCollectionFromGroup>as containing one child,<groupName>(this is the element used to make the request):C. JAXB honors the
processContentsattribute of<xs:any>(see Mapping of <xs:any />). WhenprocessContents='strict', JAXB tries to match (and marshall) the child elements based on the namespace they belong to.D. The WSDL schema definition for the
<GetUserCollectionFromGroupResult>includes<xs:any>:E. When
processContentsis omitted, the default isstrict.Thus, when JAX-WS/JAXB processes the results from the web service, it tries to marshall the children of
<GetUserCollectionFromGroupResult>using the schema. The children appear in the response as belonging to the same namespace as the request. When the<GetUserCollectionFromGroup>element is processed, it is marshalled to an instance of the same class used in the request for the<GetUserCollectionFromGroup>element. Thus, you are effectively blocked from getting at the<Users>elements.I’ve searched high and low, and the only solution(s) that I can find is to ether (a) edit the WSDL as described at the start of this answer, or (b) edit the generated stubs. Not ideal, but unavoidable in this case.
More information about the
<xs:any>schema element (and theprocessContentsattribute) can be found on MSDN here.