diff --git a/v2alpha/soap/client/client.go b/v2alpha/soap/client/client.go index 3bbc9b2..a0958e0 100644 --- a/v2alpha/soap/client/client.go +++ b/v2alpha/soap/client/client.go @@ -57,21 +57,6 @@ func New(endpointURL string, opts ...Option) *Client { } } -// PerformAction makes a SOAP request, with the given `argsIn` as input -// arguments, and `argsOut` to capture the output arguments into. -// `serviceType` is the SOAP service type URN, `actionName` is the action to -// call. -// -// This is a convenience for calling `c.Do` without creating `*Action` values. -func (c *Client) PerformAction( - ctx context.Context, serviceType, actionName string, - argsIn, argsOut any, -) error { - actionIn := envelope.NewSendAction(serviceType, actionName, argsIn) - actionOut := &envelope.Action{Args: argsOut} - return c.Do(ctx, actionIn, actionOut) -} - // PerformAction makes a SOAP request, with the given action values to provide // arguments (`args`) and capture the `reply` into. func (c *Client) Do( @@ -100,6 +85,22 @@ func (c *Client) Do( return ParseResponseAction(resp, actionOut) } +// PerformAction makes a SOAP request, with the given `argsIn` as input +// arguments, and `argsOut` to capture the output arguments into. +// `serviceType` is the SOAP service type URN, `actionName` is the action to +// call. +// +// This is a convenience for calling `Client.Do` without creating `*Action` values. +func PerformAction( + ctx context.Context, c *Client, + serviceType, actionName string, + argsIn, argsOut any, +) error { + actionIn := envelope.NewSendAction(serviceType, actionName, argsIn) + actionOut := &envelope.Action{Args: argsOut} + return c.Do(ctx, actionIn, actionOut) +} + // SetRequestAction updates fields in `req` with the given SOAP action. // Specifically it sets Body, ContentLength, Method, and the SOAPACTION and // CONTENT-TYPE headers. diff --git a/v2alpha/soap/client/client_test.go b/v2alpha/soap/client/client_test.go index ea2353c..e749c27 100644 --- a/v2alpha/soap/client/client_test.go +++ b/v2alpha/soap/client/client_test.go @@ -75,7 +75,7 @@ func (fss *fakeSoapServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } -func TestDo(t *testing.T) { +func TestPerformAction(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) t.Cleanup(cancel) @@ -91,12 +91,10 @@ func TestDo(t *testing.T) { c := New(ts.URL + "/endpointpath") - reqAction := envelope.NewSendAction("http://example.com/endpointns", "Foo", - &ActionArgs{Name: "World"}) reply := &ActionReply{} - replyAction := &envelope.Action{Args: reply} - if err := c.Do(ctx, reqAction, replyAction); err != nil { + if err := PerformAction(ctx, c, "http://example.com/endpointns", "Foo", + &ActionArgs{Name: "World"}, reply); err != nil { t.Errorf("got error: %v, want success", err) } else { if got, want := reply.Greeting, "Hello, World!"; got != want {