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 Test Web Service Callouts.

WebServiceMock Methods

The following are methods for WebServiceMock.

doInvoke(stub, soapRequest, responseMap, endpoint, soapAction, requestName, responseNamespace, responseName, responseType)

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 soapRequest, Map<String,Object> responseMap, String endpoint, String soapAction, String requestName, String responseNamespace, String responseName, String responseType)

Parameters

stub
Type: Object
An instance of the auto-generated class.
soapRequest
Type: Object
The SOAP Web service request being invoked.
responseMap
Type: Map<String, Object>
A collection of key/value pairs representing the response to send for the request.
When implementing this interface, set the responseMap 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.
responseNamespace
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