membrane / soa-model

Toolkit and Java API for WSDL, WADL and XML Schema.
http://www.membrane-soa.org/soa-model/
Apache License 2.0
94 stars 73 forks source link

improve namespace prefix evaluation logic #291

Open isc-pfp opened 1 year ago

isc-pfp commented 1 year ago

This is probably still not perfect. However, sending a request with a prefixed root and un-prefixed child element to a web-service does not work for me. And with this change, child elemnts are also prefixed, and the service call I am testing works now.

I tested this by generating a request for a webservice I am working on and then submitting it, using a IntellIJ .http file that I generated using the SOARequestCreator.createRequest() util method.

After this commit, the resulting request looks like this and works:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:GetBusinessObject xmlns:ns1='http://client.example.com/xyz/v1'>
      <!-- from 0 to unbounded -->
      <ns1:objectId>0</ns1:objectId>
    </ns1:GetBusinessObject>
  </s11:Body>
</s11:Envelope>

Before this commit, the resulting request looks like this and does not work - the service implementation code sees an empty list [] of "objectId"s instead of [1]:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:GetBusinessObject xmlns:ns1='http://client.example.com/xyz/v1'>
      <!-- from 0 to unbounded -->
      <objectId>0</objectId>
    </ns1:GetBusinessObject>
  </s11:Body>
</s11:Envelope>

FTR, the IntelliJ "request" in the test-service.http file I use, looks like this:

POST http://localhost:12345/xyz/XyzV1
Content-Type: text/xml

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
...
</s11:Envelope>