0

Editted as this was getting messy and moving off-topic.

I had a WSDL URL showing the XML code which was to be used for submitting test data. I have no experience with XML and intend to edit it, adding values, using Excel VBA.

My first query was how to input a value to a field. I was attempting to manually alter the element text.

e.g. for the name element, I was adding a value to name at the end.

<element name="name" minOccurs="1" maxOccurs="1">
<simpleType>
<restriction base="string">
<maxLength value="47"/>
</restriction>
</simpleType>
</element>

And I change the first line to

<element name="name" minOccurs="1" maxOccurs="1" value="Name is required">

As Tim pointed out, this is not the correct way to do this. In the code I submit, that line should read

<name>Name is required</name>

In VBA I had been using this code to post the amended xml file, but I am still not sure if this is correct.

Sub SendXMLtoTEST()
    Dim myHTTP As New MSXML2.XMLHTTP60
    Dim myDom As New MSXML2.DOMDocument60
    Dim myXML As String
    'Set myHTTP = CreateObject("msxml2.xmlhttp")
    'Set myDom = CreateObject("MSXML2.DOMDocument")
    'myDom.async = False      '"?API=Verify&XML=" &

    'myDom.LoadXML (myXML)
    myDom.Load "C:\Users\me\Desktop\test.xml"
    myHTTP.Open "post", SAAserver, False
    'myHTTP.setRequestHeader "Content-Type", "text/xml" '"application/x-www-form-urlencoded"
    myHTTP.send (myDom.XML)
    MsgBox myHTTP.responseText
End Sub

I downloaded SoapUI 5.3 and created a new SOAP project from the XML code in the WSDL URL. Right clicked Project and selected New SOAP mockservice Right clicked mockservice and selected New mockoperation This gave me the soap envelope, header and body. I then amended the body code for the fields I needed (Removing any ampersands!!). This I copied and put in the request editor to submit.

This seems to work okay from SoapUI but I can't seem to get it to work when posting from VBA (at least I can't see how to test if it is working or not).

I will start a new thread for that as my original query of adding the values has been answered.

Glib
  • 242
  • 2
  • 4
  • 16
  • Thanks for that Tim. I actually started off doing that, but didn't have a clue about the prolog and headers required. I'll edit and add some other code that also didn't seem to pass muster. – Glib Jul 17 '17 at 21:45
  • I'm not able to read a WSDL and create a submission either - do they not have any examples ? – Tim Williams Jul 17 '17 at 21:46
  • They had a PDF listing the mandatory fields, but no examples. – Glib Jul 17 '17 at 21:52
  • 1
    A few ideas here: https://stackoverflow.com/questions/35908226/generating-request-response-xml-from-a-wsdl – Tim Williams Jul 17 '17 at 22:00

0 Answers0