Newer Version Available

This content describes an older version of this product. View Latest

WebServiceMock Interface

Enables sending fake responses when testing Web service callouts of a class auto-generated from a WSDL.

Namespace

System

Usage

For an implementation example, see Testing Web Service Callouts.

WebServiceMock Methods

The following are methods for WebServiceMock.

doInvoke(Object, Object, Map<String, Object>, String, String, String, String, String, String)

The implementation of this method is called by the Apex runtime to send a fake response when a Web service callout is made after Test.setMock has been called.

Signature

public Void doInvoke(Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String responseName, String responseType)

Parameters

stub
Type: Object
An instance of the auto-generated class.
request
Type: Object
The SOAP Web service request being invoked.
response
Type: Map<String, Object>
A collection of key/value pairs representing the response to send for the request.
When implementing this interface, set the response argument to a key/value pair representing the response desired.
endpoint
Type: String
The endpoint URL for the request.
soapAction
Type: String
The requested SOAP operation.
requestName
Type: String
The requested SOAP operation name.
responseNS
Type: String
The response namespace.
responseName
Type: String
The name of the response element as defined in the WSDL.
responseType
Type: String
The class for the response as defined in the auto-generated class.

Return Value

Type: Void

Usage