Remove an empty declaration from XML tag - xmlns=""

Hey,

I'm consuming a method from a SOAP WS and I wanted to remove the following empty declaration in one of the attributes tag:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Header>
      <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="1">XXXXXXXXXXXXXXXXXX</wsa:Action>
      <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="1">uuid:35891380-8d8f-40be-827b-70982f72f34f</wsa:MessageID>
      <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="1">XXXXXXXXXXXXXXXXXX</wsa:To>
      <wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="1">
          http://www.w3.org/2005/08/addressing/anonymous
      </wsa:ReplyTo>
   </soap:Header>
   <soap:Body>
      <CESPedidoSituacaoContribADSE xmlns="XXXXXXXXXXXXXXXXXX">
         <IdentificacaoBeneficiarioPTVO_1 xmlns="">
            <utilizador>SICOFADMIN</utilizador>
            <dataConsentimento>2018-10-29</dataConsentimento>
            <niss>10751078814</niss>
         </IdentificacaoBeneficiarioPTVO_1>
      </CESPedidoSituacaoContribADSE>
   </soap:Body>
</soap:Envelope>


The method we want to consume already has a 'predefined' structure, which we can't change. We only fill out its values and when we call the WS method OS generates the XML and sends it with that empty declaration

is it possible for me to remove this declaration?

I want to mention that I'm using OS 9 at the moment and I don't have access to the reference in c# so atm I can't extend anything.

Outsystems.SOAP.API;


If you guys could share like an old tutorial of extensions or a more in-depth guide or even the references that I need to use to try to extend this I would fully appreciate it, 


Thank you so much for reading,

VC

Solution


Sometimes you want to consume a web service which has some particularity that makes Outsystems generate a badly built request. In my case it was a prefix in nodes like so <prefix:node1>....</prefix:node1>. There was no way I could fix the soap message unless I intercepted the outbound message in the server and made the needed alterations, but this option is not always possible and it's a bit more painful to maintain too since you distribute spots of change.

Which brings me to what this tutorial is about: Consuming a web service in an extension and then referencing the extension


First Step:

Open Integration Studio and name your new extension

You should then create actions for each web service operation that you need, maybe you need all of them, maybe you don't. Sometimes we reference a web service with 20 operations and use only one.

These actions usually need parameters so we need to define them too, anything that is a complexType in the WSDL should be represented as a record or list of records.

Lets say MyWSAction exposed by the web service takes 2 parameters, a String called Phrase and a complex type called Limits with 2 integers (Lower and Upper).

We go ahead and define the structures and set them as parameters to MyWSAction like so:

After you defined all your input and output parameters we're ready to edit the extension.

Second Step:

So now we that we have stubs for all the extension's actions, we need to consume the web service in our extension and make the bridge to the web service parameters. We start by adding a service reference ? Advanced ? Add Web Reference ? Paste the wsdl into the url box and then click Add Reference (these steps might vary depending on your Visual Studio version)



Visual Studio generated all the required code to make the web service calls as we can see, we have a class for our WS handler and a class for the Limits parameter, it also generates a configuration file with the URL of the web service but it can and should still explicitly be set using MyWS.Url


Now we need to instantiate the MyWS class and translate our parameters from the outsystems generated classes to the web service generated classes, here's a snippet of code exemplifying:


In this example we don't have lists of records but you should be aware that if you do, there needs to be verification for empty lists before you try to access list element attributes.

Don't forget, if your operations have outputs and they're also complex types you need to do the reverse before you assign them to the outsystems output parameters.


Third Step


Publish your extension and use it in service studio just like any other extension, except it's a web service.

Solution

I had an old tutorial I made for internal use in my company that I shared in the post above. Hope it helps !

I feel that you updated your answers and corrected the images, thank you so much for that... I will very soon look into it and will keep you informed

but,

thanks a lot for taking time to read and for posting a real possible solution to lots of kinds of problems related to SOAP WS,

Talk to you soon and thanks once again

Cheers

VC

Yes I did, there were some broken url's :)

It's fine I had it done already! Anyways I'll just add that the .NET import of the webservice isn't always done the way I did it so try different ways until you get a good result.

Cheers

Hey,

So I tried to implement it first using WCF but with no success, because with WCF I could not add the WS Addressing, which is a specification I need in this WS, even though I could remove the empty tag. 

So I was thinking to myself, why not RAW XML, so I decided to formulate the entire XML only defining a few header parameters and was able to remove the empty xmlns tag.

A few hours later the client replied us it wasn't needed to remove the tag anymore so...

Now my problem is related to exposing a WS with WS Addressing if you wish to follow the post:

https://www.outsystems.com/forums/discussion/43432/expose-soap-ws-with-ws-adressing/


I will mark one of your answers as the solution since it really helped me get into it,

Cheers and thank you once again,

VC