我通过gowsdl请求接口报Found multiple elements inside SOAP body; not wrapped-document/literal WS-I compliant的错误。是什么原因引起的呢
// Code generated by gowsdl DO NOT EDIT.
package myservice
import (
"context"
"encoding/xml"
"github.com/hooklift/gowsdl/soap"
"time"
)
// against "unused imports"
var _ time.Time
var _ xml.Name
type AnyType struct {
InnerXML string `xml:",innerxml"`
}
type AnyURI string
type NCName string
type Param struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema Login"`
UserName string `xml:"userName,omitempty" json:"userName,omitempty"`
Password string `xml:"password,omitempty" json:"password,omitempty"`
SlnName string `xml:"slnName,omitempty" json:"slnName,omitempty"`
DcName string `xml:"dcName,omitempty" json:"dcName,omitempty"`
Language string `xml:"language,omitempty" json:"language,omitempty"`
DbType string `xml:"dbType" json:"dbType"`
}
type WSContext struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema LoginResponse"`
DbType int32 `xml:"dbType,omitempty" json:"dbType,omitempty"`
DcName string `xml:"dcName,omitempty" json:"dcName,omitempty"`
Password string `xml:"password,omitempty" json:"password,omitempty"`
SessionId string `xml:"sessionId,omitempty" json:"sessionId,omitempty"`
SlnName string `xml:"slnName,omitempty" json:"slnName,omitempty"`
UserName string `xml:"userName,omitempty" json:"userName,omitempty"`
}
type EASLoginProxy interface {
Login(request *Param) (*WSContext, error)
LoginContext(ctx context.Context, request *Param) (*WSContext, error)
}
type eASLoginProxy struct {
client *soap.Client
}
func NewEASLoginProxy(client *soap.Client) EASLoginProxy {
return &eASLoginProxy{
client: client,
}
}
func (service *eASLoginProxy) Login(request *Param) (*WSContext, error) {
return service.LoginContext(
context.Background(),
request,
)
}
func (service *eASLoginProxy) LoginContext(ctx context.Context, request *Param) (*WSContext, error) {
response := new(WSContext)
err := service.client.CallContext(ctx, "''", request, response)
if err != nil {
return nil, err
}
return response, nil
}
ChatGPT尝试为您解答,仅供参考
这个错误通常是由于请求的 SOAP 消息中包含了多个元素,但是没有包装在文档/文字形式的外部元素中。这不符合 WS-I(Web Services Interoperability)规范。
为了解决这个问题,可能需要修改请求消息的格式,使其符合 WS-I 规范的要求。这可能需要包装请求消息中的元素,使其在文档/文字形式的外部元素中。具体修改方式可能因请求消息的结构而异。
如果你正在使用 gowsdl 库来生成代码,你可能还需要检查你使用的 WSDL 文件是否符合 WS-I 规范,并确保 gowsdl 在生成代码时遵循了这些规范。
这个错误可能是由于在SOAP消息体中包含了多个元素导致的。根据WS-I约束,SOAP消息体中应该只包含一个元素。
可以考虑将多个元素包装在一个父元素中,然后将该父元素作为SOAP消息体中的唯一元素传递。
例如,假设想要在SOAP消息体中传递用户名和密码,可以创建一个名为“Credentials”的父元素,然后将用户名和密码作为该父元素的子元素传递。
gowsdl请求接口报
Found multiple elements inside SOAP body; not wrapped-document/literal WS-I compliant
报错含义:在SOAP主体中找到多个元素;不包装文档/文字WS-I兼容
主要分析方向,WS-I兼容问题,看一下WS-I规范。
Go调用webservice
可以借鉴下
https://blog.csdn.net/sinat_34898805/article/details/104943117