GithubHelp home page GithubHelp logo

Comments (8)

gboor avatar gboor commented on August 29, 2024 1

@creativesuraj https://docs.python-zeep.org/en/master/

from goxmldsig.

muhRobai avatar muhRobai commented on August 29, 2024

i think you can using struct tag like this, for set prefix SOAP-ENV

//swagger:model Envelop
type Envelope struct {
	XMLName      xml.Name   `xml:"SOAP-ENV:Envelope"`
	XSDAttr      string     `xml:"xmlns:xsd,attr"`
	XSIAttr      string     `xml:"xmlns:xsi,attr"`
	EnvelopeAttr string     `xml:"xmlns:SOAP-ENV,attr"`
	SoapEncAttr  string     `xml:"xmlns:SOAP-ENC,attr"`
	Body         ThreeParty `xml:"SOAP-ENV:Body"`
}

from goxmldsig.

gboor avatar gboor commented on August 29, 2024

Thanks for the idea, but that sadly does not work, since the whole document already exists before I sign it and the namespace is not on the node.

I noticed that implementations of C14N in other languages actually copies the namespace from parent nodes when you try to canonicalize a single node, but this library does not...

Is there some way to fix that?

from goxmldsig.

creativesuraj avatar creativesuraj commented on August 29, 2024

@gboor Are you able to sign the SOAP xml?
I'm stuck with signing SOAP xml payload in Go. Didn't find a working library yet.

Thanks

from goxmldsig.

gboor avatar gboor commented on August 29, 2024

@creativesuraj I was never able to make it work with SOAP. I switched the whole code base to Python eventually. Sorry I can't be more helpful.

from goxmldsig.

creativesuraj avatar creativesuraj commented on August 29, 2024

@gboor which python library are you using?

from goxmldsig.

creativesuraj avatar creativesuraj commented on August 29, 2024

Thanks

from goxmldsig.

gboor avatar gboor commented on August 29, 2024

If anyone is still tracking this / interested; I eventually managed to make this work in GO using https://github.com/textnow/gosoap.

Here is an example using both transport certs and WSSE;

package main

import (
	"context"
	"crypto/tls"
	"encoding/xml"
	soap "github.com/Enflick/gosoap"
	"net/http"
	"time"
)

type ListMessageMetadataRequest struct {
	XMLName xml.Name `xml:"http://sys.svc.tennet.nl/MMCHub/v1 listMessageMetadataRequest"`

	Receiver string `xml:"receiver"`
}

type ListMessageMetadataResponse struct {
	XMLName xml.Name `xml:"http://sys.svc.tennet.nl/MMCHub/v1 listMessageMetadataResponse"`

	MessageMetadata []struct {
		TechnicalMessageId string    `xml:"technicalMessageId"`
		ReceivedTimestamp  time.Time `xml:"receivedTimestamp"`
		MessageType        string    `xml:"messageType"`
		ContentType        string    `xml:"contentType"`
		CorrelationId      string    `xml:"correlationId"`
		Sender             string    `xml:"sender"`
		Receiver           string    `xml:"receiver"`
	} `xml:"messageMetadata,omitempty"`
}

func main() {
	wsseInfo, _ := soap.NewWSSEAuthInfo("path-to-cert.pem", "path-to-pk.pem")
	cert, _ := tls.LoadX509KeyPair("path-to-transport-cert.pem", "path-to-transport-key.pem")

	tlsConfig := &tls.Config{
		Certificates: []tls.Certificate{cert},
	}

	transport := &http.Transport{TLSClientConfig: tlsConfig}
	httpClient := &http.Client{Transport: transport}
	soapClient := soap.NewClient(httpClient)

	body := ListMessageMetadataRequest{
		Receiver: "some_id",
	}

	res := ListMessageMetadataResponse{}

	fault := soap.Fault{}
	soapRequest := soap.NewRequest("action", "url", &body, &res, &fault)
	soapRequest.SignWith(wsseInfo)
	
	soapResponse, _ := soapClient.Do(context.Background(), soapRequest)
	if soapResponse.StatusCode == http.StatusOK {
		// Do some stuff with res
	}
}

from goxmldsig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.