Question: The EU VIES VAT validation from WSDL is not working when running via java code. But the same is working from some soap API testing tools.
 Eg, <https://wsdlbrowser.com/soapclient?wsdl_url=https%3A%2F%2Fec.europa.eu%2Ftaxation_customs%2Fvies%2FcheckVatService.wsdl> and <https://app.boomerangapi.com/?ext>

Even its not working when I trid to get source code from wsimport. (C:\Program Files\Java\jdk1.8.0\_151\bin>wsimport -keep -verbose <http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl>)

Error is “The element type "BR" must be terminated by the matching end-tag "".” The same error is coming when trying to access SOAP service via java code.

Any suggestions on how to use this EU wsdl for validating VAT nos?

Answer: 
Assuming it's for browser.. you could create a new script tag (so that the content of the javascript file will be parsed) and then assign the new variable from there.
Here is some code for reference:

```
const newScriptTag = document.createElement('script')
newScriptTag.textContent = content; // content is the value of the js file (var oc... )
document.body.append(newScriptTag)
let newArray = oc;
// then remove the script tag
document.body.removeChild(scriptTag)

```
Well, you could get rid go the prefix and suffix of your string using something like:

```
let result = 'var oc=["object_1", "object_2"];';
result = result.replace('var oc=','');//to remove the variable definition from the start
result = result.slice(0,-1);//to remove ';' at the end. You can use this, because strings are arrays of characters

```

And then use:

```
result = JSON.parse(result);//this should give you a nice array with your objects in it

```

You can find references for the methods I mentioned from a couple of different sources:

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse>

<https://www.w3schools.com/jsref/jsref_replace.asp>

<https://www.w3schools.com/jsref/jsref_slice_array.asp>

**EDIT**:
That last part with `JSON.parse()` would work if the return for your request was a valid JSON. but it's not, that's JS code, representing the definition of an object. To parse that, you could use `eval()`. But you should exercise caution and only use that in strings that return from trustworthy sources, since that could inadvertently execute malicious code inside your code.
That said, the last line of code to solve your problem would be something like:

```
result = eval(result)
console.log(result);

```

Thankfully, there's a better way to do it using `Function()` like so:

```
result = Function('"use strict";return (' + result + ')')
console.log(result());

```

You can read the reference from these two last ways of parsing code as string in here: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Never_use_eval>!