msxml Parsing Soap Response using MS DOM and classic asp - msxml

I am using classic "ASP" dont bea me up. Just havent been able to make the jump to .Net yet. I am just learning soap and have successfully creates a SOAP request to a webservice. However, I am unable to figure out how to parse the response and pull out a single node. I am using MS DOM to load the response into a Document. I can get the response to screen. I have tried the following but I am unable to get to any nodes_text individually.
'Set the XML Object
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
'Set Asynchoronous = false
xmlDoc.async = False
'Load the XML file.
'User Server.MapPath method is the XML is located in your site.
'Else you can use the absolute path.
xmlDoc.Load (strResult)
'If there is any errors pasring the file the notify
If xmlDoc.parseError.errorCode = 0 Then
Response.Write "Error Parsing XML"
Response.Write "Rason :" & xmlDoc.parseError.reason & "Error Line: " & xmlDoc.parseError.line
End If
'Get ALL the Elements by the tag name book
Set sessionid = xmlDoc.getElementsByTagName("session_id")
'Now Iterate through the List and Display
response.write"sessionid ="&sessionid&"<BR>"
For i = 0 to (sessionid.Length-1)
Response.Write "session_id " & sessionid.item(i).childNodes(0).text & "<br/>"
Next
Here is a response I am trying to parse
<ns:getSessionResponse xmlns:ns="http://services.axis.openmeetings.org">
<ns:return xmlns:ax217="http://basic.beans.data.app.openmeetings.org/xsd"
xmlns:ax218="http://basic.beans.hibernate.app.openmeetings.org/xsd"
type="org.openmeetings.app.hibernate.beans.basic.Sessiondata">
<ax218:id>71</ax218:id>
<ax218:language_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:organization_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:refresh_time>2010-11-04T15:17:13.717Z</ax218:refresh_time>
<ax218:sessionXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:session_id>5f0415d9cdb72681816095debf3735de</ax218:session_id>
<ax218:starttermin_time>2010-11-04T15:17:13.717Z</ax218:starttermin_time>
<ax218:storePermanent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:user_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
</ns:return>
</ns:getSessionResponse>
I need to pull the session_id from this pare but just dont seem to be able to do it. And yes I am looking to move to .NET soon.

If strResult is a URL to the xml file then you can use:
xmlDoc.Load(strResult)
But if strResult represents the content of xml, you need to use:
xmlDoc.LoadXML(strResult)
For more information, please refer to MSDN.

Related

Can't Get the Syntax to Work for this XML Soap Request - 400 Error

Working with a SOAP API in React JS and all is fine except for this one function keeps returning a 400 error.
Using Axios to make the POST request with the following syntax.
The goal is to obtain a specific client ID and be able to edit specified fields.
let getExtraInfo = `<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateClientAdditionalFields xmlns="http://www.ozsoft.com.au/VETtrak/api/complete">
<token>${token}</token>
<clientCode>09224</clientCode>
<additionalFieldData>
<AdditionalData>
<Gender>M</Gender>
</AdditionalData>
</additionalFieldData>
</UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
Here is a link to the API
https://sthservices.ozsoft.com.au/SIU_API/VT_API.asmx?op=UpdateClientAdditionalFields
I have tried every combination to get the request to work correctly but I believe the issue may be to incorrect syntax on the API end.
For reference here is my API call using Axios.
async function GetTimetableData(xmlsChosen){
const response = await axios.post('https://thingproxy.freeboard.io/fetch/https://sthservices.ozsoft.com.au/SIU_API/VT_API.asmx?wsdl',
xmlsChosen,
{
headers:{
'Content-Type': 'text/xml'}
}).then(res=>{
var jsonObj = parse(res.data);
// setCourseChosen(jsonObj.["soap:Envelope"]["soap:Body"].GetOccurrenceExtendedDetailsResponse.GetOccurrenceExtendedDetailsResult.OccuExtended);
console.log(jsonObj);
}).catch(err=>{console.log(err);
}).finally(() => {
});
}
Would anyone be able to provide some insight as to how to do this request using React JS. I have asked the devs directly but their responses are in PHP and doesn't help with this specific issue.
The list of additional fields can also be found here.
https://customer.vettrak.com.au/hc/en-us/articles/360002285835
I can provide more information if needed.
UPDATE
I have added the headers and checked that the token is correct - I also don't have issues making other requests with the token with other functions.
I have tried the syntax below.
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>676767676</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData>"<com:AdditionalData><com:Gender>M></com:Gender></com:AdditionalData>"</com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><AdditionalData><Gender>M><Gender><AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
If I do the following request
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><com:AdditionalData>string</com:AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
I get a "A problem occurred when parsing the additional data XML: Data at the root level is invalid. Line 1, position 1." Error. I know the token and client code are fine as when I don't include them I get an Authentication Error / Client doesn't exist response.
Then when I do:
`<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>${token}</com:token>
<com:clientCode>09224</com:clientCode>
<com:additionalFieldData><com:AdditionalData><gender>M</gender><com:/AdditionalData></com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>`
I get the usual 400 error.
After looking at the UpdateClientAdditionalFields inside the WSDL, it seems one of your parameters is wrong. The top element is defined as:
<s:element name="UpdateClientAdditionalFields">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="token" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="clientCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="additionalFieldData" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
additionalFieldData is a string, but you are sending an XML in your message:
<additionalFieldData>
<AdditionalData>
<Gender>M</Gender>
</AdditionalData>
</additionalFieldData>
Try with a string or without this field just to see if it works (since it is optional minOccurs="0").
Also, your token may be wrong:
<token>${token}</token>
Is this a variable that you need to replace before the call?
Add also a HTTP header named SOAPAction like this:
SOAPAction: "http://www.ozsoft.com.au/VETtrak/api/complete/UpdateClientAdditionalFields"
Try again with these changes and see if it works.
EDIT based on comments:
Are you sending proper values for the token, clientCode, and additionalFieldData elements? I mean actual, usable values, all of type string, not placeholders like ${token} or XML elements instead of string values?
Your SOAP request should look like this (don't forget to add the SOAPAction HTTP header):
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://www.ozsoft.com.au/VETtrak/api/complete">
<soap:Body>
<com:UpdateClientAdditionalFields>
<com:token>proper value here</com:token>
<com:clientCode>proper value here</com:clientCode>
<com:additionalFieldData>proper value here</com:additionalFieldData>
</com:UpdateClientAdditionalFields>
</soap:Body>
</soap:Envelope>

Geoserver SLD Style - Space in propertyName

I'm trying to set up an sld style in Geoserver which references a column in a PostGIS view "Route Type". I'd like to have spaces in my column names as my goal is to create user friendly views for all my spatial data. With the sld below I get an error. I've tried a substituting the space for   as well as <![CDATA[Property Name]]>
None of these resolve the issue.
Is it possible to have spaces in propertyName?
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>Truck Routes and Restrictions</Name>
<UserStyle>
<Title>Truck Routes and Restrictions</Title>
<FeatureTypeStyle>
<Rule>
<Name>Designated Municipal Truck Route</Name>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>Route Type</ogc:PropertyName>
<ogc:Literal>*Designated Municipal Truck Route*</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#006600</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
As I read here PropertyName should be able to be retrieved by Web Feature Service. And next I read How to request WFS propertyName containing parentheses, where I read all this kind of elements must match XML element naming, which don't allows any spaces.
So you can't use space in PropertyName. You should use "my column names" in way that will be not able to see for yours users.

Anypoint Studio console execution does not go past deployed

Below is the configuration xml of my small program in Anypoint Studio. What i am trying to do is copying one text file data(pipe delimited) to another text file. The execution goes well but stops at status as "Deployed". I have tried other transformations as well but the result is same. Help is highly appreciable. Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<flow name="texttoexcelFlow" doc:id="42aaa83a-e26a-4f6d-8d2f-da3613a8d232" initialState="started">
<file:read doc:name="Read" doc:id="89fa46c9-aa14-4a79-b7ab-e609b9fad501" path="D:\Mulesoft Input\Name.txt" outputMimeType="application/json" outputEncoding="UTF-8">
<repeatable-in-memory-stream />
</file:read>
<ee:transform doc:name="Transform Message" doc:id="86dc86b8-99ed-4bee-b5bc-e07616e44431" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/csv headerLineNumber = 0 , header = false , separator = "|"
---
payload map ( payload01 , indexOfPayload01 ) -> {
FirstName: payload01.FirstName ,
LastName: payload01.LastName
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<file:write doc:name="Write" doc:id="3884725e-3870-4ef1-9e05-b10a2274dfa6" path="C:\Users\aseem\Desktop\Mulesoft Output\Excel.txt">
</file:write>
</flow>
</mule>
"
You need something to trigger the flow to run. file:read doesn’t do this automatically.
All flows need a ‘Source’ to trigger them unless you are calling them from other flows using flow-ref (or from dataweave using a lookup()).
If you know the exact file you want then you can put a scheduler before your file:read to trigger the flow:
<scheduler>
<scheduling-strategy>
<fixed-frequency startDelay="5" frequency="10" timeUnit="SECONDS"/>
</scheduling-strategy>
</scheduler>
Or you can use a file:listener to listen for new files in a directory etc as the source directly:
<flow name="onNewFile">
<file:listener config-ref="file" directory="test-data/in" autoDelete="true">
<scheduling-strategy>
<fixed-frequency frequency="1000"/>
</scheduling-strategy>
</file:listener>
...
</flow>
You can use fixed frequency or cron. More details here: https://docs.mulesoft.com/mule-runtime/4.1/scheduler-xml-reference

Amazon MWS: getting error 99019 for XML productFeeds (SubmitFeed of type _POST_PRODUCT_DATA_)

When I try to add a product (via a SubmitFeed of type "_POST_PRODUCT_DATA_") to the Amazon Market via the Amazon MWS API I get the following error:
[Marketplace : Amazon.de] A valid value is required in either the
"quantity" or "fulfillment_center_id" field.
But there is no "quantity" or "fulfillment_center_id" field in my Product.xsd nor in the official documentation. Also the exact same feed does work without an error on my Amazon MWS sandbox account. What am I missing?
Complete XML:
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope>
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXX</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>123456</SKU>
<StandardProductID>
<Type>EAN</Type>
<Value>767715012826</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_TAX</ProductTaxCode>
<Condition>
<ConditionType>New</ConditionType>
<ConditionNote>Zustand/condition: neu OVP</ConditionNote>
</Condition>
<DescriptionData>
<Title>Bellydance for Fitness and Fun</Title>
<Manufacturer>New World 2011</Manufacturer>
</DescriptionData>
<ProductData>
<Music>
<ProductType>
<MusicPopular>
<MediaType>audioCD</MediaType>
<NumberOfDiscs>1</NumberOfDiscs>
<Genre>New Age</Genre>
</MusicPopular>
</ProductType>
</Music>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
Make sure that you use the correct "Merchant Token" (NOT merchant id) in the tag "MerchantIdentifier" inside your feed (this isn't well documented).
<MerchantIdentifier>YOUR_MERCHANT_TOKEN</MerchantIdentifier>
You should see your Merchant Token by navigating to Sellercentral > Settings > Account Info and clicking on Your Merchant Token inside the box Business Information. If the Merchant Token isn't there (which was a common error in the past), contact the Seller Support and ask for the correct Merchant Token: Please send me my Merchant Token (NOT merchant id) for use with 3rd party software.
Try to omit additional tags describing the product, especially the whole <ProductData> section inside the <Product> element. Whenever i specified the <ProductData> section I got error 99019.
The field names in MWS error messages do not match the XML structure. I'm assuming they match the flat file (CSV) columns, but haven't actually checked.
You stated "I try to add a product", while I'm guessing that above error happened when subitting an inventory feed, which is why you won't find the anything of that sort in Product.xsd.
The corresponding XML elements are Quantity and FulfillmentCenterID, both defined in Inventory.xsd.

using dbunit to clean insert in a db from ant target

I use dbunit to test db operations in my webapp.Recently ,I used dbunits ant task org.dbunit.ant.DbUnitTask to create an xml representation of items in my database.I got this
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<table name="AUTHOR">
<column>AUTHOR_ID</column>
<column>AUTHOR_NAME</column>
<column>AUTHOR_ADDRESS</column>
<row>
<value>0</value>
<value>j.k.rowling</value>
<value>london</value>
</row>
<row>
<value>1</value>
<value><![CDATA[stephen king]]></value>
<value><![CDATA[castle rock,maine]]></value>
</row>
</table>
...
I wanted to clean insert into the db ,values from this xml file.In a testcase's you do this by
public void init() throws FileNotFoundException, IOException, ClassNotFoundException, SQLException, DatabaseUnitException {
connection = DbUnitUtils.createConnection();
try {
DatabaseOperation.CLEAN_INSERT.execute(connection,DbUnitUtils.createDataSet("initialdata.xml"));
}finally {
connection.close();
}
}
I wanted to do the same using an ant target.So I wrote
<target name="insertdata" depends="startdb">
<dbunit driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}">
<operation type="CLEAN_INSERT" src="data/dbunit/initialdata.xml"/>
</dbunit>
</target>
<taskdef
name="dbunit"
classname="org.dbunit.ant.DbUnitTask"
classpathref="clientclasspath"
/>
where the driver.username,password etc are taken from a properties file
However,I get this error
insertdata:
[dbunit] Executing operation: CLEAN_INSERT
[dbunit] on file: C:\code\jee\myapp\data\dbunit\initialdata.xml
[dbunit] with format: null
[dbunit] 550 [main] ERROR org.dbunit.database.DatabaseDataSet - Table 'value' not found in tableMap=org.dbunit.dataset.OrderedTableNameMa
p[_tableNames=[AUTHOR], _tableMap={AUTHOR=null}, _caseSensitiveTableNames=false]
Can anyone make sense of this error?The same xml file when passed to the method DatabaseOperation.CLEAN_INSERT.execute(connection,DbUnitUtils.createDataSet("initialdata.xml"))
succeeds in cleanly inserting the data.
Any help welcome
thanks
mark
I'm not sure what the DbUnitUtils.createDataSet() method is up to, but it looks like you may need to specify the format for the XML as xml - i.e. conforming to the fixed DTD of an XMLDataSet. The Ant task assumes flat format if you don't specify one, and flat format doesn't look like your example XML.
<operation type="CLEAN_INSERT" src="data/dbunit/initialdata.xml" format="xml" />
See Parameters specified as nested elements for operation.

Resources