Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification to allow attributes in SOAP requests #37

Closed
wants to merge 1 commit into from

Conversation

kvbkvm
Copy link

@kvbkvm kvbkvm commented Sep 30, 2019

Hi,

The SOAP WS that I'm using needs some attributes in the SOAP requests. There was a similar idea in issue #8 made by cscholle1.

Here's my working proposal:
params := gosoap.Params{ "sIp[type=s:string,anotherAttribute=anotherValue]": "8.8.8.8", }
Thx,
kvbkvm

@@ -52,19 +53,42 @@ type tokenData struct {
func (tokens *tokenData) recursiveEncode(hm interface{}) {
v := reflect.ValueOf(hm)

regexpAttrBox := regexp.MustCompile(`([^\[]+)\[(.*)\]`)
regexpAttrs := regexp.MustCompile(`,?([^=]+)=([^,]+)`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the line 56 and 57 to the case case reflect.Map.

var attrs []xml.Attr
matches := regexpAttrs.FindAllStringSubmatch(rs[2], -1)
for _, match := range matches {
attrs = append(attrs, xml.Attr{Name: xml.Name{Local: match[1]}, Value: match[2]})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you know the size of matches, please create the variable attrs using that information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants