github.com/vmware/govmomi@v0.51.0/vim25/soap/soap.go (about)

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package soap
     6  
     7  import (
     8  	"github.com/vmware/govmomi/vim25/types"
     9  	"github.com/vmware/govmomi/vim25/xml"
    10  )
    11  
    12  // HeaderElement allows changing the default XMLName (e.g. Cookie's default of vcSessionCookie)
    13  type HeaderElement struct {
    14  	XMLName xml.Name
    15  	Value   string `xml:",chardata"`
    16  }
    17  
    18  // Header includes optional soap Header fields.
    19  type Header struct {
    20  	Action   string         `xml:"-"`                         // Action is the 'SOAPAction' HTTP header value. Defaults to "Client.Namespace/Client.Version".
    21  	Cookie   *HeaderElement `xml:"vcSessionCookie,omitempty"` // Cookie is a vCenter session cookie that can be used with other SDK endpoints (e.g. pbm, vslm).
    22  	ID       string         `xml:"operationID,omitempty"`     // ID is the operationID used by ESX/vCenter logging for correlation.
    23  	Security any            `xml:",omitempty"`                // Security is used for SAML token authentication and request signing.
    24  }
    25  
    26  type Envelope struct {
    27  	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
    28  	Header  *Header  `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header,omitempty"`
    29  	Body    any
    30  }
    31  
    32  type Fault struct {
    33  	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
    34  	Code    string   `xml:"faultcode"`
    35  	String  string   `xml:"faultstring"`
    36  	Detail  struct {
    37  		Fault types.AnyType `xml:",any,typeattr"`
    38  	} `xml:"detail"`
    39  }
    40  
    41  func (f *Fault) VimFault() types.AnyType {
    42  	return f.Detail.Fault
    43  }