changeset 5618:57c655b93ba8 erdms2

Suppress namespace for erdms.GetRisDataXML SOAP call args.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 28 Nov 2022 17:11:43 +0100
parents 6c17583ff3c1
children f0413b20ad4d
files pkg/imports/erdms.go pkg/soap/erdms2/service.go pkg/soap/soap.go
diffstat 3 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/erdms.go	Tue Nov 15 14:54:38 2022 +0100
+++ b/pkg/imports/erdms.go	Mon Nov 28 17:11:43 2022 +0100
@@ -87,16 +87,18 @@
 	client := erdms.NewRefService(URL, insecure, auth)
 
 	var responseData []*erdms.GetRisDataXMLResponse
+
+	fcode := erdms.NoNS{Text: funcode}
 	for _, country := range countries {
 
 		feedback.Info("Request RIS index for country %s", country)
 
-		subcode := erdms.RisCodeType(country + "%")
+		subcode := erdms.NoNS{Text: country + "%"}
 
 		request := &erdms.GetRisDataXML{
 			GetRisDataXMLType: &erdms.GetRisDataXMLType{
 				Subcode: &subcode,
-				Funcode: funcode,
+				Funcode: &fcode,
 			},
 		}
 
--- a/pkg/soap/erdms2/service.go	Tue Nov 15 14:54:38 2022 +0100
+++ b/pkg/soap/erdms2/service.go	Mon Nov 28 17:11:43 2022 +0100
@@ -827,14 +827,20 @@
 	RefdataReturn []*RefdataReturnType `xml:"refdataReturn,omitempty" json:"refdataReturn,omitempty"`
 }
 
+// NoNS is a helper type to allow string tags without a namespace.
+type NoNS struct {
+	NS   string `xml:"xmlns,attr"`
+	Text string `xml:",chardata"`
+}
+
 type GetRisDataXMLType struct {
-	Funcode string `xml:"funcode,omitempty" json:"funcode,omitempty"`
-
-	CountryCode *CountryCodeType `xml:"countryCode,omitempty" json:"countryCode,omitempty"`
+	Funcode *NoNS `xml:"funcode,omitempty" json:"funcode,omitempty"`
+
+	CountryCode *NoNS `xml:"countryCode,omitempty" json:"countryCode,omitempty"`
 
 	Page *PageRequestType `xml:"page,omitempty" json:"page,omitempty"`
 
-	Subcode *RisCodeType `xml:"subcode,omitempty" json:"subcode,omitempty"`
+	Subcode *NoNS `xml:"subcode,omitempty" json:"subcode,omitempty"`
 
 	Version *RefrecVersionType `xml:"version,omitempty" json:"version,omitempty"`
 }
--- a/pkg/soap/soap.go	Tue Nov 15 14:54:38 2022 +0100
+++ b/pkg/soap/soap.go	Mon Nov 28 17:11:43 2022 +0100
@@ -251,7 +251,7 @@
 	buffer := new(bytes.Buffer)
 
 	encoder := xml.NewEncoder(buffer)
-	//encoder.Indent("", "    ")
+	encoder.Indent("", "    ")
 
 	if err := encoder.Encode(envelope); err != nil {
 		return err
@@ -261,6 +261,10 @@
 		return err
 	}
 
+	if log.GetLogLevel() >= log.DebugLogLevel {
+		log.Debugf("SOAP message:\n%s\n", buffer.String())
+	}
+
 	req, err := http.NewRequest("POST", s.url, buffer)
 	if err != nil {
 		return err
@@ -330,6 +334,8 @@
 		return nil
 	}
 
+	log.Debugf("length response: %d\n", len(rawbody))
+
 	//log.Debugln(string(rawbody))
 	respEnvelope := new(SOAPEnvelope)
 	respEnvelope.Body = SOAPBody{Content: response}