-
Notifications
You must be signed in to change notification settings - Fork 391
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
Incorrect namespace handling #232
Comments
Hi @w65536. Do you have a capture of the raw response the server sends back, and the service's WSDL? If the service you're taking to expects an un-namespaced Unfortunately, Go's XML support is so broken that I don't know if the right thing can be done in both cases. |
So I was able to capture the raw SOAP request/response before and after the change. It is all simplified and sanitized to just expose the problem. Before #218:
After #218:
This is the diff of above traces: --- soap-simplified-before-218-sanitized.log 2021-12-08 17:10:39.000000000 +0100
+++ soap-simplified-after-218-sanitized.log 2021-12-08 17:10:39.000000000 +0100
@@ -1,7 +1,7 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<operationX xmlns="http://www.example.com/service/v1">
- <request xmlns="http://www.example.com/service/v1" id="1234">
+ <request xmlns="http://www.example.com/service/v1" xmlns:v1="http://www.example.com/service/v1" v1:id="1234">
<userId>8888</userId>
<orderNr>9876</orderNr>
</request>
@@ -14,7 +14,7 @@
<soapenv:Header/>
<soapenv:Body>
<v1:operationXResponse xmlns:v1="http://www.example.com/service/v1">
- <v1:response id="1234">
+ <v1:response>
<v1:success>true</v1:success>
</v1:response>
</v1:operationXResponse> You can see that the server no longer responds with the After seeing this, I realize that already before the change from #218 do I get a panic if I do not send the attribute in the request at all. I am seeing the following panic in all cases where the server responds without the
So the problem here is twofold:
Bottom line:
Here is the simplified and sanitized WSDL for reference: <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.com/service/ws/V001"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsg="http://www.example.com/service/v1"
xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/"
name="ServiceV001"
targetNamespace="http://www.example.com/service/ws/V001">
<wsdl:types>
<xsd:schema xmlns="http://www.example.com/service/v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsg="http://www.example.com/service/v1"
targetNamespace="http://www.example.com/service/v1"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:element name="operationX">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="request" type="wsg:operationXRequestType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="operationXResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="response" type="wsg:operationXAckType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="operationXRequestType">
<xsd:complexContent>
<xsd:extension base="requestType">
<xsd:sequence>
<xsd:choice>
<xsd:element ref="orderNr"/>
</xsd:choice>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="operationXAckType">
<xsd:complexContent>
<xsd:extension base="ackType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="requestType" abstract="true">
<xsd:complexContent>
<xsd:extension base="messageType">
<xsd:sequence>
<xsd:element ref="userId"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ackType" abstract="true">
<xsd:complexContent>
<xsd:extension base="messageType">
<xsd:sequence>
<xsd:element ref="success"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="messageType" abstract="true">
<xsd:attribute name="id" type="idType" use="optional"/> <!-- HERE IS THE ATTRIBUTE -->
</xsd:complexType>
<xsd:element name="success" type="xsd:boolean">
</xsd:element>
<xsd:element name="userId">
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:totalDigits value="6"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="orderNr" type="orderNrType">
</xsd:element>
<xsd:simpleType name="orderNrType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[1-9]\d{25}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="idType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="operationXRequest">
<wsdl:part name="parameters" element="wsg:operationX"/>
</wsdl:message>
<wsdl:message name="operationXResponse">
<wsdl:part name="parameters" element="wsg:operationXResponse"/>
</wsdl:message>
<wsdl:portType name="Wsg">
<wsdl:operation name="operationX">
<wsdl:input message="tns:operationXRequest"/>
<wsdl:output message="tns:operationXResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WsgSoapBinding" type="tns:Wsg">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="operationX">
<soap:operation soapAction="https://www.example.com/wsg-outbound/services/ServiceV001/operationX"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WsgService">
<wsdl:port name="ServiceV001" binding="tns:WsgSoapBinding">
<soap:address location="https://www.example.com/wsg-outbound/services/ServiceV001"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
Thanks for the response. The issue here is this part of the XSD: <xsd:schema … attributeFormDefault="unqualified"> Which indicates that attributes shouldn't be qualified with the Since these are defaults, I assume they can also change per The fix is to add a conditional around these two lines in This is a thing I could look at implementing, but don't have much bandwidth to take on at the moment. I see you've opened some PRs already, so maybe this is sufficient guidance for you to fix it. |
Thanks for your insights. I get what you are saying and it is helpful indeed. I guess I might be able to fix this, but I also need to check my time management. I will try to look into it, if I can find some time. Do you have any insights whatsoever on problem 2: |
I'm not sure. The stacktrace you shared is entirely inside of |
I am afraid the change introduced with #218 breaks a few things. I have not had the time to properly analyze this. But this is what I see so far.
Before, this is what my request and response looked like:
Now this is what the request looks like:
Trying to marshal the response for printing panics. I speculate this is because the service does not respond in the format that is now expected by the generated Go code:
panic: reflect: call of reflect.Value.CanInterface on zero Value
The text was updated successfully, but these errors were encountered: