public class Service
extends java.lang.Object
Service
instances are not. State on the client is
maintained between interactions in order to support features such as update
management.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
WCF_DATASERVICES_METADATA_NAMESPACE
WCF data services metadata namespace.
|
static java.lang.String |
WCF_DATASERVICES_NAMESPACE
WCF data services namespace.
|
static java.lang.String |
WCF_DATASERVICES_SCHEME_NAMESPACE
WCF data services scheme namespace.
|
Constructor and Description |
---|
Service(Reference serviceRef)
Constructor.
|
Service(java.lang.String serviceUri)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntity(java.lang.String entitySetName,
java.lang.Object entity)
Adds an entity to an entity set.
|
void |
addLink(java.lang.Object source,
java.lang.String sourceProperty,
java.lang.Object target)
Adds an association between the source and the target entity via the
given property name.
|
<T> Query<T> |
createQuery(java.lang.String subpath,
java.lang.Class<T> entityClass)
Creates a query to a specific entity hosted by this service.
|
ClientResource |
createResource(Reference reference)
Returns an instance of
ClientResource given an absolute
reference. |
ClientResource |
createResource(java.lang.String relativePath)
Returns an instance of
ClientResource given a path (relative to
the service reference). |
void |
deleteEntity(java.lang.Object entity)
Deletes an entity.
|
void |
deleteEntity(java.lang.String entitySubpath)
Deletes an entity.
|
void |
deleteLink(java.lang.Object source,
java.lang.String sourceProperty,
java.lang.Object target)
Removes the association between a source entity and a target entity via
the given property name.
|
java.lang.String |
getClientVersion()
Returns the version of the OData protocol extensions defined in every
request issued by this service.
|
ChallengeResponse |
getCredentials()
Returns the credentials used to authenticate requests.
|
Request |
getLatestRequest()
Returns the latest request sent to the service.
|
Response |
getLatestResponse()
Returns the response to the latest request.
|
java.lang.String |
getMaxClientVersion()
Returns the maximum version of the OData protocol extensions the client
can accept in a response.
|
protected java.lang.Object |
getMetadata()
Returns the metadata document related to the current service.
|
java.lang.String |
getServerVersion()
Returns the version of the OData protocol extensions supported by the
remote service.
|
Reference |
getServiceRef()
Returns the reference to the WCF service.
|
Representation |
getValue(java.lang.Object entity)
Returns the binary representation of the given media resource.
|
Representation |
getValue(java.lang.Object entity,
java.util.List<Preference<MediaType>> acceptedMediaTypes)
Returns the binary representation of the given media resource.
|
Representation |
getValue(java.lang.Object entity,
MediaType mediaType)
Returns the binary representation of the given media resource.
|
Reference |
getValueRef(java.lang.Object entity)
Returns the reference of the binary representation of the given entity,
if this is a media resource.
|
Representation |
invokeComplex(java.lang.String service,
Series<Parameter> parameters)
Invokes a service operation and return the raw representation sent back
by the service.
|
java.lang.String |
invokeSimple(java.lang.String service,
Series<Parameter> parameters)
Invokes a service operation and return the String value sent back by the
service.
|
void |
loadProperty(java.lang.Object entity,
java.lang.String propertyName)
Updates the given entity object with the value of the specified property.
|
void |
setClientVersion(java.lang.String clientVersion)
Sets the version of the OData protocol extensions defined in every
request issued by this service.
|
void |
setCredentials(ChallengeResponse credentials)
Sets the credentials used to authenticate requests.
|
void |
setLatestRequest(Request latestRequest)
Sets the latest request sent to the service.
|
void |
setLatestResponse(Response latestResponse)
Sets the response to the latest request.
|
void |
setLink(java.lang.Object source,
java.lang.String sourceProperty,
java.lang.Object target)
Sets the association between the source and the target entity via the
given property name.
|
void |
setMaxClientVersion(java.lang.String maxClientVersion)
Sets the maximum version of the OData protocol extensions the client can
accept in a response.
|
void |
setValue(java.lang.Object entity,
Representation blob)
Sets the value of the given media entry link.
|
Entry |
toEntry(java.lang.Object entity)
Converts an entity to an Atom entry object.
|
void |
updateEntity(java.lang.Object entity)
Updates an entity.
|
public static final java.lang.String WCF_DATASERVICES_METADATA_NAMESPACE
public static final java.lang.String WCF_DATASERVICES_NAMESPACE
public static final java.lang.String WCF_DATASERVICES_SCHEME_NAMESPACE
public Service(Reference serviceRef)
serviceRef
- The reference to the WCF service.public Service(java.lang.String serviceUri)
serviceUri
- The URI of the WCF service.public void addEntity(java.lang.String entitySetName, java.lang.Object entity) throws java.lang.Exception
entitySetName
- The path of the entity set relatively to the service URI.entity
- The entity to put.java.lang.Exception
public void addLink(java.lang.Object source, java.lang.String sourceProperty, java.lang.Object target) throws java.lang.Exception
source
- The source entity to update.sourceProperty
- The name of the property of the source entity.target
- The entity to add to the source entity.java.lang.Exception
public <T> Query<T> createQuery(java.lang.String subpath, java.lang.Class<T> entityClass)
T
- The class of the target entity.subpath
- The path to this entity relatively to the service URI.entityClass
- The target class of the entity.public ClientResource createResource(Reference reference)
ClientResource
given an absolute
reference. This resource is completed with the service credentials. This
method can be overriden in order to complete the sent requests.reference
- The reference of the target resource.ClientResource
.public ClientResource createResource(java.lang.String relativePath)
ClientResource
given a path (relative to
the service reference). This resource is completed with the service
credentials. This method can be overriden in order to complete the sent
requests.relativePath
- The relative reference of the target resource.ClientResource
given a path (relative to
the service reference).public void deleteEntity(java.lang.Object entity) throws ResourceException
entity
- The entity to deleteResourceException
public void deleteEntity(java.lang.String entitySubpath) throws ResourceException
entitySubpath
- The path of the entity to deleteResourceException
public void deleteLink(java.lang.Object source, java.lang.String sourceProperty, java.lang.Object target) throws ResourceException
source
- The source entity to update.sourceProperty
- The name of the property of the source entity.target
- The entity to delete from the source entity.ResourceException
public java.lang.String getClientVersion()
public ChallengeResponse getCredentials()
public Request getLatestRequest()
public Response getLatestResponse()
public java.lang.String getMaxClientVersion()
protected java.lang.Object getMetadata()
public java.lang.String getServerVersion()
public Reference getServiceRef()
public Representation getValue(java.lang.Object entity) throws ResourceException
entity
- The given media resource.ResourceException
public Representation getValue(java.lang.Object entity, java.util.List<Preference<MediaType>> acceptedMediaTypes) throws ResourceException
entity
- The given media resource.acceptedMediaTypes
- The requested media types of the representation.ResourceException
public Representation getValue(java.lang.Object entity, MediaType mediaType) throws ResourceException
entity
- The given media resource.mediaType
- The requested media type of the representationResourceException
public Reference getValueRef(java.lang.Object entity)
entity
- The media resource.public Representation invokeComplex(java.lang.String service, Series<Parameter> parameters) throws ResourceException
service
- The name of the service.parameters
- The list of required parameters.ResourceException
- Thrown when the service call is not successfull.public java.lang.String invokeSimple(java.lang.String service, Series<Parameter> parameters) throws ResourceException, java.lang.Exception
service
- The name of the service.parameters
- The list of required parameters.ResourceException
- Thrown when the service call is not successfull.java.lang.Exception
- Thrown when the value cannot be parsed.public void loadProperty(java.lang.Object entity, java.lang.String propertyName)
entity
- The entity to update.propertyName
- The name of the property.public void setClientVersion(java.lang.String clientVersion)
clientVersion
- The version of the OData protocol extensions defined in every
request issued by this service.public void setCredentials(ChallengeResponse credentials)
credentials
- The credentials used to authenticate requests.public void setLatestRequest(Request latestRequest)
latestRequest
- The latest request sent to the service.public void setLatestResponse(Response latestResponse)
latestResponse
- The response to the latest request.public void setLink(java.lang.Object source, java.lang.String sourceProperty, java.lang.Object target) throws java.lang.Exception
source
- The source entity to update.sourceProperty
- The name of the property of the source entity.target
- The entity to add to the source entity.java.lang.Exception
public void setMaxClientVersion(java.lang.String maxClientVersion)
maxClientVersion
- The maximum version of the OData protocol extensions the
client can accept in a response.public void setValue(java.lang.Object entity, Representation blob) throws ResourceException
entity
- The media entry link which value is to be updatedblob
- The new representation.ResourceException
public Entry toEntry(java.lang.Object entity)
entity
- The entity to wrap.public void updateEntity(java.lang.Object entity) throws java.lang.Exception
entity
- The entity to put.java.lang.Exception
Copyright © 2005-2020 Restlet.