From 5c55e505487d73b1b4d7328ca6f808c956cadba1 Mon Sep 17 00:00:00 2001 From: John Beisley Date: Thu, 5 Jun 2014 22:38:04 +0100 Subject: [PATCH] Encode the SOAP action element. It should always have included this. It probably never worked properly before, except for servers that didn't require arguments or the action element. --- soap/soap.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/soap/soap.go b/soap/soap.go index b8a2f49..5072157 100644 --- a/soap/soap.go +++ b/soap/soap.go @@ -13,7 +13,7 @@ import ( const ( soapEncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/" - soapPrefix = `` + soapPrefix = `` soapSuffix = `` ) @@ -30,7 +30,7 @@ func NewSOAPClient(endpointURL url.URL) *SOAPClient { // PerformSOAPAction makes a SOAP request, with the given action. func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAction interface{}, outAction interface{}) error { - requestBytes, err := encodeRequestAction(inAction) + requestBytes, err := encodeRequestAction(actionNamespace, actionName, inAction) if err != nil { return err } @@ -85,15 +85,23 @@ func newSOAPEnvelope() *soapEnvelope { // 500s for requests where the outer default xmlns is set to the SOAP // namespace, and then reassigning the default namespace within that to the // service namespace. Hand-coding the outer XML to work-around this. -func encodeRequestAction(inAction interface{}) ([]byte, error) { +func encodeRequestAction(actionNamespace, actionName string, inAction interface{}) ([]byte, error) { requestBuf := new(bytes.Buffer) requestBuf.WriteString(soapPrefix) + requestBuf.WriteString(``) if inAction != nil { requestEnc := xml.NewEncoder(requestBuf) if err := requestEnc.Encode(inAction); err != nil { return nil, err } } + requestBuf.WriteString(``) requestBuf.WriteString(soapSuffix) return requestBuf.Bytes(), nil }