How to get the namespace, method, soap_action from a wsdl file - web-services

I have a WSDL file that displayed below :
<wsdl:definitions targetNamespace="urn:sap-com:document:sap:rfc:functions"><wsdl:documentation><sidl:sidl/></wsdl:documentation><wsp:UsingPolicy wsdl:required="true"/><wsp:Policy wsu:Id="BN__binding"><wsp:ExactlyOne><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="BN__binding_soap12"><wsp:ExactlyOne><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All><wsp:All><sapattahnd:Enabled>false</sapattahnd:Enabled><saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/><wsaw:UsingAddressing wsp:Optional="true"/><wsp:All><sp:TransportBinding><wsp:Policy><sp:TransportToken><wsp:Policy><sp:HttpsToken><wsp:Policy><sp:HttpBasicAuthentication/></wsp:Policy></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy><sp:Basic128Rsa15/></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy><sp:Strict/></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="IF__ztm_ws_get_emp_holidays"><wsp:ExactlyOne><wsp:All><sapsession:Session><sapsession:enableSession>false</sapsession:enableSession></sapsession:Session><sapcentraladmin:CentralAdministration wsp:Optional="true"><sapcentraladmin:BusinessApplicationID>005056AC6E191ED3979A90345DADF406</sapcentraladmin:BusinessApplicationID></sapcentraladmin:CentralAdministration></wsp:All></wsp:ExactlyOne></wsp:Policy><wsp:Policy wsu:Id="OP__Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsp:ExactlyOne><wsp:All><saptrhnw05:required>no</saptrhnw05:required><sapcomhnd:enableCommit>false</sapcomhnd:enableCommit><sapblock:enableBlocking>true</sapblock:enableBlocking><saprmnw05:enableWSRM>false</saprmnw05:enableWSRM></wsp:All></wsp:ExactlyOne></wsp:Policy><wsdl:types><xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions"><xsd:simpleType name="char1"><xsd:restriction base="xsd:string"><xsd:maxLength value="1"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char10"><xsd:restriction base="xsd:string"><xsd:maxLength value="10"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char20"><xsd:restriction base="xsd:string"><xsd:maxLength value="20"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char220"><xsd:restriction base="xsd:string"><xsd:maxLength value="220"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char30"><xsd:restriction base="xsd:string"><xsd:maxLength value="30"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char32"><xsd:restriction base="xsd:string"><xsd:maxLength value="32"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char40"><xsd:restriction base="xsd:string"><xsd:maxLength value="40"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="char50"><xsd:restriction base="xsd:string"><xsd:maxLength value="50"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="date10"><xsd:restriction base="xsd:string"><xsd:maxLength value="10"/><xsd:pattern value="\d\d\d\d-\d\d-\d\d"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric3"><xsd:restriction base="xsd:string"><xsd:maxLength value="3"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric6"><xsd:restriction base="xsd:string"><xsd:maxLength value="6"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="numeric8"><xsd:restriction base="xsd:string"><xsd:maxLength value="8"/><xsd:pattern value="\d*"/></xsd:restriction></xsd:simpleType><xsd:complexType name="ZTMSHOLIDAYS"><xsd:sequence><xsd:element name="DATE" type="tns:date10"/><xsd:element name="DESCRIPTION" type="tns:char40"/></xsd:sequence></xsd:complexType><xsd:complexType name="BAPIRET2"><xsd:sequence><xsd:element name="TYPE" type="tns:char1"/><xsd:element name="ID" type="tns:char20"/><xsd:element name="NUMBER" type="tns:numeric3"/><xsd:element name="MESSAGE" type="tns:char220"/><xsd:element name="LOG_NO" type="tns:char20"/><xsd:element name="LOG_MSG_NO" type="tns:numeric6"/><xsd:element name="MESSAGE_V1" type="tns:char50"/><xsd:element name="MESSAGE_V2" type="tns:char50"/><xsd:element name="MESSAGE_V3" type="tns:char50"/><xsd:element name="MESSAGE_V4" type="tns:char50"/><xsd:element name="PARAMETER" type="tns:char32"/><xsd:element name="ROW" type="xsd:int"/><xsd:element name="FIELD" type="tns:char30"/><xsd:element name="SYSTEM" type="tns:char10"/></xsd:sequence></xsd:complexType><xsd:complexType name="ZTMTT_HOLIDAYS"><xsd:sequence><xsd:element name="item" type="tns:ZTMSHOLIDAYS" minOccurs="0" maxOccurs="unbounded"/></xsd:sequence></xsd:complexType><xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><xsd:complexType><xsd:sequence><xsd:element name="PI_PERNR" type="tns:numeric8"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"><xsd:complexType><xsd:sequence><xsd:element name="PE_I_HOLIDAYS" type="tns:ZTMTT_HOLIDAYS"/><xsd:element name="PE_MESSAGE" type="tns:BAPIRET2"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsdl:part name="parameters" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/></wsdl:message><wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"><wsdl:part name="parameter" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/></wsdl:message><wsdl:portType name="ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#IF__ztm_ws_get_emp_holidays"/></wsp:Policy><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsp:Policy><wsp:PolicyReference URI="#OP__Z_TM_ETM_GET_EMPL_HOLIDAYS"/></wsp:Policy><wsdl:input message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/><wsdl:output message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/></wsdl:operation></wsdl:portType><wsdl:binding name="binding" type="tns:ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#BN__binding"/></wsp:Policy><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><soap:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding name="binding_soap12" type="tns:ztm_ws_get_emp_holidays"><wsp:Policy><wsp:PolicyReference URI="#BN__binding_soap12"/></wsp:Policy><wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS"><wsoap12:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/><wsdl:input><wsoap12:body use="literal"/></wsdl:input><wsdl:output><wsoap12:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="OfficialHolidays"><wsdl:port name="binding" binding="tns:binding"><soap:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/></wsdl:port><wsdl:port name="binding_soap12" binding="tns:binding_soap12"><wsoap12:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/></wsdl:port></wsdl:service></wsdl:definitions>
I want to know these values form it:
namespace
soap action
method name
what are they ?

definitions targetNamespace="http://worldheritage.org/"
so your name space is
NameSpace = urn:sap-com:document:sap:rfc:functions
operation name="YourMethodName"
and method name is
method name="Z_TM_ETM_GET_EMPL_HOLIDAYS
Server URL is
soap:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"

Related

When merging multiple xml files, how can I set EntityResolver for child xml files as well besides the parent xml?

I have a book xml file which references other multiple xml files. When I try to run an xslt on the book.xml file, the EntityResolver in my code resolves the dtd path. However, for the children xml files which are being merged, the dtd paths are not resolved.
Sample sample_book.ditamap
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd">
<bookmap>
<booktitle>
<mainbooktitle>sample book</mainbooktitle>
</booktitle>
<part navtitle="Overview">
<topicref href="../topics/introduction.dita"/>
<topicref href="../topics/install.dita"/>
</part>
</bookmap>
`
Java Code
public class XMLProcessor {
public void transform(String xmlf, String xslf) throws TransformerConfigurationException, TransformerException, org.xml.sax.SAXException, IOException{
org.xml.sax.XMLReader reader = XMLReaderFactory.createXMLReader();
Transformer transformer;
TransformerFactory factory = TransformerFactory.newInstance();
StreamSource stylesheet = new StreamSource(xslf);
//Source source = StreamSource(xmlf);
//SAXSource source = new SAXSource(new InputSource(xmlf));
// org.xml.sax.XMLReader reader = XMLReaderFactory.createXMLReader();
EntityResolver ent = new EntityResolver() {
#Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
System.out.println(publicId);
System.out.println(systemId);
if(publicId.equals("-//OASIS//DTD DITA BookMap//EN")){
return new InputSource("file:///D:/sample/dtd/bookmap.dtd");
}
return null;
}
};
// sour.setPublicId("file:///D:/sample/dtd/bookmap/dtd/bookmap.dtd");
reader.setEntityResolver(ent);
SAXSource source = new SAXSource(reader, new InputSource(xmlf));
//reader.parse(new InputSource(xmlf));
//StreamSource sourcedoc = new StreamSource(xmlf);
transformer = factory.newTransformer(stylesheet);
try {
transformer.transform(source, new StreamResult(new FileWriter("D:\\sample\\out\\result.xml")));
} catch (IOException ex) {
Logger.getLogger(XMLProcessor.class.getName()).log(Level.SEVERE, null, ex);
}
}
}`
Expected Result
`
<?xml version="1.0" encoding="UTF-8"?>
<pages xmlns:mf="urn:mf">
<parentpage>
<parentpagename>sample book</parentpagename>
</parentpage>
<part>
<partname>Overview</partname>
<text/>
<level-2>
<concept xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
id="introduction" ditaarch:DITAArchVersion="1.3"
domains="(topic concept) (topic abbrev-d) a(props deliveryTarget) (topic equation-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic mathml-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic svg-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d) "
class="- topic/topic concept/concept ">
<title class="- topic/title ">Introduction</title>
<shortdesc class="- topic/shortdesc "/>
<conbody class="- topic/body concept/conbody ">
<p class="- topic/p ">Sample introduction</p>
</conbody>
</concept>
</level-2>
<text/>
<level-2>
<task xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" id="install"
ditaarch:DITAArchVersion="1.3"
domains="(topic task) (topic abbrev-d) a(props deliveryTarget) (topic equation-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic mathml-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic svg-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d) (topic task strictTaskbody-c) "
class="- topic/topic task/task ">
<title class="- topic/title ">Install</title>
<shortdesc class="- topic/shortdesc "/>
<taskbody class="- topic/body task/taskbody ">
<context class="- topic/section task/context ">
<p class="- topic/p ">Download xyz installer from here. </p>
</context>
<steps class="- topic/ol task/steps ">
<step class="- topic/li task/step ">
<cmd class="- topic/ph task/cmd ">Double-click the downloader
installer.</cmd>
</step>
<step class="- topic/li task/step ">
<cmd class="- topic/ph task/cmd ">Do this.</cmd>
</step>
<step class="- topic/li task/step ">
<cmd class="- topic/ph task/cmd ">Do that</cmd>
</step>
</steps>
</taskbody>
</task>
</level-2>
</part>
</pages>
`
Actual Result
When the XSLT is run, the following error message is displayed. The error goes away, when I move the dtd files to the topics folder.
Warning XTDE0540: Ambiguous rule match for /bookmap/booktitle[1] Matches both "element(Q{}booktitle)" on line 54 of
>file:///D:/sample/xsl/merge.xsl and "element(Q{}booktitle)" on line 18 of >file:///D:/sample/xsl/merge.xsl Warning at char 11 in
xsl:apply-templates/#select on line 30 column 104 of >merge.xsl:
FODC0002: I/O error reported by XML parser processing
file:/D:/sample/sampledoc/topics/introduction.dita:
D:\sample\sampledoc\topics\concept.dtd (The system cannot find the
file specified) Warning at char 11 in xsl:apply-templates/#select on line 30 column 104 of >merge.xsl: FODC0002: I/O error reported by
XML parser processing file:/D:/sample/sampledoc/topics/install.dita:
D:\sample\sampledoc\topics\task.dtd (The system cannot find the >file
specified)
You can set a URIResolver on the Transformer, which will be called when your XSLT code calls doc() or document() to fetch the referenced XML files. The URIResolver can then set an EntityResolver on the XML parser used to parse these files.
Alternatively you can do all of this with the Apache XMLResolver which deferences URIs at both the XSLT and the XML level by reference to a catalog file in a format defined by OASIS.
Thanks to Michael, I could resolve this issue.
Added a CatalogManager.properties file in the classpath.
Created a catalog.xml with all public ids.
public class XMLProcessor {
public void transform(String xmlf, String xslf, String outpath) throws TransformerConfigurationException, TransformerException, org.xml.sax.SAXException, IOException{
org.xml.sax.XMLReader reader = XMLReaderFactory.createXMLReader();
Transformer transformer = null;
TransformerFactory factory = TransformerFactory.newInstance();
StreamSource stylesheet = new StreamSource(xslf);
CatalogResolver cr = new CatalogResolver();
reader.setEntityResolver(cr);
factory.setURIResolver(cr);
SAXSource source = new SAXSource(reader, new InputSource(xmlf));
transformer = factory.newTransformer(stylesheet);
try {
transformer.transform(source, new StreamResult(new FileWriter(outpath)));
} catch (IOException ex) {
Logger.getLogger(XMLProcessor.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

Copy operator not working in Quick Fast C++

Now currently I am working on copy operator. What I understand from all the document and other material available on net is that Quickfast maintains a dictionary which is used by multiples entries within a UDP message to check the previous value.
eg: Lets say in the below given template we can have multiple MDEntries depending upon NoMDEntries tag value. Lets say we have 2 as the value .
What I did was , I put the value of MDEntryType (with copy oprerator ) as 1 (some random value) in the first entry, but for the second entry I did not put any value.
After I decode the message the value of MDEntryType should be 1 for both the entries.
Is my understanding correct ?
<template dictionary="1" id="1" name="MDIncRefreshSample_1">
<string id="35" name="MessageType">
<constant value="X"></constant>
</string> <string id="49" name="SenderCompID">
<constant value="Client"></constant>
</string> <string id="56" name="TargetCompID">
<constant value="Server"></constant>
</string> <uint32 id="34" name="MsgSeqNum"></uint32>
<uint64 id="52" name="SendingTime"></uint64>
<sequence name="MDEntries">
<length id="268" name="NoMDEntries"></length>
<uint32 id="279" name="MDUpdateAction">
<copy value="1"></copy>
</uint32>
<string id="269" name="MDEntryType">
<copy value="0"></copy>
</string>
<uint32 id="278" name="MDEntryID"></uint32>
<uint32 id="48" name="SecurityID">
<delta></delta>
</uint32>
<decimal id="270" name="MDEntryPx">
<exponent>
<default value="-2"></default>
</exponent>
<mantissa>
<delta></delta>
</mantissa>
</decimal>
<int32 id="271" name="MDEntrySize">
<delta></delta>
</int32>
<string id="37" name="OrderID"></string>
<uint32 id="273" name="MDEntryTime">
<copy></copy>
</uint32>
</sequence>
</template>
Now when I try to implement the above in my code, I am not able to copy the value in the second entry.
Here is the snippet of the code I used (help taken from testRoundTrip.cpp)
Template Created :
<templates>
<template dictionary="InstrumentReferenceData"
name="InstrumentReferenceData" id="3">
<typeRef name="instrumentreferencedata"/>
<uInt32 name="timestamp" id="52"> <delta/> </uInt32>
<uInt32 name="srcId" id="50"> <copy/> </uInt32>
<uInt32 name="seqNum" id="34"> <increment value="1"/> </uInt32>
<uInt32 name="isix" id="48"> <delta/> </uInt32>
<string name="isin" id="455"> <delta/> </string>
<string name="exchId" id="207"> <copy/> </string>
<string name="instGrp" id="1151"> <copy/> </string>
<string name="instTypCod" id="461"> <copy/> </string>
<string name="currCode" id="15"> <copy/> </string>
<decimal name="ticSiz" id="969"> <delta/> </decimal>
<uInt32 name="setId" id="TBD"> <copy/> </uInt32>
<sequence name="MDFeedTypes">
<length name="noOfStreams" id="1141"/>
<string name="streamType" id="1022"> <copy dictionary="template" />
</string>
<string name="streamService"> <copy/> </string>
<string name="inetAddr"> <delta/> </string>
<uInt32 name="port" id="TBD"> <delta/> </uInt32>
<uInt32 name="mktDepth" id="264" presence="optional"/> </uInt32>
<uInt32 name="mdBookType" id="1021" presence="optional"/> </uInt32>
</sequence>
</template>
</templates>
Message creation plus encoding and decoding: (I have poulated the value in streamtype field only once)
Messages::MessagePtr msg(new Messages::Message(templateRegistry->maxFieldCount()));
msg->addField(identity_timestamp, Messages::FieldUInt32::create(1));
msg->addField(identity_srcId, Messages::FieldUInt32::create(2));
msg->addField(identity_seqNum, Messages::FieldUInt32::create(3));
msg->addField(identity_isix, Messages::FieldUInt32::create(4));
msg->addField(identity_isin, Messages::FieldAscii::create("isin"));
msg->addField(identity_exchId, Messages::FieldAscii::create("exchId"));
msg->addField(identity_instGrp, Messages::FieldAscii::create("instGrp"));
msg->addField(identity_instTypCod, Messages::FieldAscii::create("instTypCod"));
msg->addField(identity_currCode, Messages::FieldAscii::create("currCode"));
msg->addField(identity_ticSiz, Messages::FieldDecimal::create(Decimal(123, -1)));
msg->addField(identity_setId, Messages::FieldUInt32::create(5));
lengthIdentity.setId("1141");
Messages::SequencePtr sequence_MDFeedTypes(new Messages::Sequence(lengthIdentity, 2));
Messages::FieldSetPtr entry(new Messages::FieldSet(6)); // todo Hardcoded 6?
entry->addField(identity_streamType, Messages::FieldAscii::create("streamType")); // Populated the value 1st time
entry->addField(identity_streamService, Messages::FieldAscii::create("streamService"));
entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.com"));
entry->addField(identity_port, Messages::FieldUInt32::create(2222));
entry->addField(identity_mktDepth, Messages::FieldUInt32::create(10));
sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));
entry.reset(new Messages::FieldSet(6));
entry->addField(identity_streamType, Messages::FieldAscii::create("")); // Did not Populate the value 2nd time
entry->addField(identity_streamService, Messages::FieldAscii::create(""));
entry->addField(identity_inetAddr, Messages::FieldAscii::create("inetAddr.org"));
entry->addField(identity_port, Messages::FieldUInt32::create(2224));
entry->addField(identity_mdBookType, Messages::FieldUInt32::create(3));
sequence_MDFeedTypes->addEntry(Messages::FieldSetCPtr(entry));
msg->addField(identity_MDFeedTypes, Messages::FieldSequence::create(sequence_MDFeedTypes));
Codecs::Encoder encoder(templateRegistry);
Codecs::DataDestination destination;
template_id_t templId = 3; // from the XML above
encoder.encodeMessage(destination, templId, *msg);
std::string fastString;
destination.toString(fastString);
std::cout<<"fastString is "<<fastString<<std::endl;
destination.clear();
Codecs::Decoder decoder(templateRegistry);
Codecs::DataSourceString source(fastString);
Codecs::SingleMessageConsumer consumer;
Codecs::GenericMessageBuilder builder(consumer);
decoder.decodeMessage(source, builder);
Messages::Message & msgOut(consumer.message());
Messages::MessageFormatter formatter(std::cout);
formatter.formatMessage(msgOut); // I have made some printing changes to print the ouptut per tag
validateMessage1(msgOut);
encoder.reset();
encoder.encodeMessage(destination, templId, msgOut);
std::string reencoded;
destination.toString(reencoded);
destination.clear();
I am able to encode and successfully decode the message, but the value is not getting copied in the second entry (streamType tag).
Here is my decoded ouput:
1st entry:
streamType[1022]=streamType
streamService[]=streamService
inetAddr[]=inetAddr.com
port[TBD]= 2045
2nd entry:
streamType[1022]= //value not copied
streamService[]=
inetAddr[]=inetAddr.org
port[TBD]= 2046
Could you please let us know, if we are making a mistake somewhere. I am very new to this :)
I have following queries too :
1/ Do we need to explicitly need to enable/disable dictionary in quickfast ? (In FIX we could do that with flag, DataDictionary = Y/N).
Also in the template created above , I found this line:
<string name="streamType" id="1022"> <copy dictionary="template" /> </string>
Is it neccesary to give dictionary name while using operators and how are they related?
2/ Do we also need to explicitly mention that PMAP bits are required?
Codecs::PresenceMap pmap(1); // I came across this function, so I got this doubt whether we need to explicitly mention about pmap.

Overwrite an existing text file c++

This is how my Save As works - it is copying the current file's lines until it reaches the first figure and then I use my print methods to print the figure's info and then close the tag.
std::ofstream newFile(filePath1_fixed, std::ios::app);
std::fstream openedFile(filePath);
std::string line1;
while (std::getline(openedFile, line1)) {
if (line1.find("<rect") != std::string::npos
|| line1.find("<circle") != std::string::npos
|| line1.find("<line") != std::string::npos)
break;
newFile << line1 << std::endl;
}
figc.printToFile(newFile);
newFile << "</svg>\n";
My question is how to save the changes to the current file? I tried something like this:
std::ifstream openedFile(filePath);
std::ofstream newFile(filePath, std::ios::app);
std::string line1;
std::string info_beg[100];
int t = 0;
while (std::getline(openedFile, line1)) {
std::cout << "HELLYEAH";
if (line1.find("<rect") != std::string::npos
|| line1.find("<circle") != std::string::npos
|| line1.find("<line") != std::string::npos)
break;
info_beg[t++] = line1;
}
for (int i = 0; i < t; i++)
newFile << info_beg[i] << std::endl;
figc.printToFile(newFile);
newFile << "</svg>\n";
This is the nearest I've gone. I get this:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example rect01 - rectangle with sharp corners</desc>
<!-- Show outline of canvas using 'rect' element -->
<rect x="1" y="1" width="1198" height="398"
fill="none" stroke="blue" stroke-width="2" />
<line x1="20" y1="100" x2="100" y2="20"
stroke="red" stroke-width="2" />
<rect x="20" y="30" width="40" height="50"
fill="red" stroke="red" stroke-width="1" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="1" />
<line x1="100" y1="200" x2="300" y2="400"
stroke="red" stroke-width="2" />
<circle cx="10" cy="20" r="30"
fill="red" stroke="blue" stroke-width="2" />
</svg>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example rect01 - rectangle with sharp corners</desc>
<!-- Show outline of canvas using 'rect' element -->
<rect x="1" y="1" width="1198" height="398"
fill="none" stroke="blue" stroke-width="2" />
<line x1="20" y1="100" x2="100" y2="20"
stroke="red" stroke-width="2" />
<rect x="20" y="30" width="40" height="50"
fill="red" stroke="red" stroke-width="1" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="1" />
<line x1="100" y1="200" x2="300" y2="400"
stroke="red" stroke-width="2" />
<circle cx="10" cy="20" r="30"
fill="red" stroke="blue" stroke-width="2" />
<rect x="10" y="20" width="30" height="40"
fill="red" stroke="blue" stroke-width="2" />
</svg>
So my actual question is how to delete the first or overwrite it or I need a different approach.
Use ios::trunc instead of ios::app
Using std::ios::app in the constructor for your std::ofstream tells the program to append to the file and not overwrite it. If you want to overwrite it (ie truncate), then using std::ios::trunc will tell the program to overwrite the existing file. ofstream does this by default, so you could just write the initialization as just std::ofstream newFile(filePath);.
Also, don't try to read the file and write to it at the same time; that won't work. Use ifstream to get the data into the buffer, then use close() to close the file. Then initialize newFile to overwrite the file and write out the buffer.

Cannot find a matching 1-argument function named

I have the following XSLT and using Stylus. No matter what I do I get the following error message for Line number 50.
Cannot find a matching 1-argument function named {http://schemas.microsoft.com/BizTalk/2003/userCSharp}ReplaceYYYMMDDtoXsdDate()
encoding="UTF-8" at the does not help.
Adding msxsl:assembly and msxsl:using do not help
Appreciate hints and help.
Regards, Toraj
<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 userCSharp ScriptNS0" version="1.0" xmlns:ns0="http://schemas.microsoft.com/dynamics/2008/01/documents/AdecPOItemArrival"
xmlns:st="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:ScriptNS0="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0">
<xsl:output indent="yes" omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates select="s0:X12_00401_856" />
</xsl:template>
<!-- Use the following inside BizTalk Scripting Fuctoid - Start -->
<xsl:template name="CopyOrderTemplate" match="s0:X12_00401_856" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006">
<xsl:copy>
<xsl:apply-templates select="s0:HLLoop1[.//HL03/text()='O']" />
</xsl:copy>
</xsl:template>
<xsl:template name="WMSJournalTableTemplate" match="s0:HLLoop1[.//HL03/text()='O']">
<ns0:WMSJournalTable class="entity" Number="{.//PRF01}">
<xsl:apply-templates select="following-sibling::s0:HLLoop1[.//HL03/text()='I'][generate-id(preceding-sibling::s0:HLLoop1[.//HL03/text()='O'][1])=generate-id(current())]" />
</ns0:WMSJournalTable>
</xsl:template>
<xsl:template name="WMSJournalTransTemplate" match="s0:HLLoop1[.//HL03/text()='I']">
<ns0:WMSJournalTrans class="entity" Number="{.//LIN01}">
<xsl:variable name="Qty" select="s0:SN1/SN102/text()" />
<ns0:Qty>
<xsl:value-of select="$Qty" />
</ns0:Qty>
<xsl:variable name="TestData" select="../s0:DTM/DTM02/text()" />
<ns0:TestDataTst>
<xsl:value-of select="$TestData" />
</ns0:TestDataTst>
<!-- From BizTalk Validate XSLT
<xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate(string(../../../s0:DTM/DTM02/text()))" /> -->
<!-- <xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate(string(../s0:DTM/DTM02/text()))"/> -->
<xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate($TestData)" />
<ns0:TransDate>
<xsl:value-of select="$var:v29" />
</ns0:TransDate>
<xsl:variable name="VendAccount" select="'13458'" />
<ns0:VendAccount>
<xsl:value-of select="$VendAccount" />
</ns0:VendAccount>
</ns0:WMSJournalTrans>
</xsl:template>
<msxsl:script language="C#" implements-prefix="userCSharp">
<!-- <msxsl:script implements-prefix='userCSharp' language='C#'>
<msxsl:assembly href="C:\Users\toraj.khavari\Documents\StylusProjects\856\Adec.Common.Modification.dll"/>
<msxsl:using namespace="Adec.Common.Modification" />
<msxsl:using namespace="System" />-->
<![CDATA[
/// <summary>
/// Replaces the yyyymmddd date to XSD date.
/// </summary>
/// <param name="stringInput">The string input.</param>
/// <returns></returns>
public string ReplaceYYYMMDDtoXsdDate(string stringInput)
{
System.String resultStr = "NotFound";
string year = null;
string month = null;
string day = null;
try
{
if (!System.String.IsNullOrEmpty(stringInput) && (stringInput.Length > 7))
{
// IsDigitsOnly
foreach (char c in stringInput)
{
if (c < '0' || c > '9')
return resultStr = "Invalid Input string values";
}
year = stringInput.Substring(0, 4);
month = stringInput.Substring(4, 2);
day = stringInput.Substring(6, 2);
resultStr = String.Format("{0}-{1}-{2}", year, month, day);
}
else
{
resultStr = "Invalid Input string values";
}
}
catch
{
resultStr = "ExceptionError in ReplaceYYYMMDDtoXsdDateTime";
}
return resultStr;
}
]]>
</msxsl:script>
<!-- Use the bove inside BizTalk Scripting Fuctoid - END -->
</xsl:stylesheet>
Code attached
Well msxsl:script is a proprietary Microsoft feature implemented in some XSLT 1.0 processor by Microsoft like the various MSXML version (which however don't support calling into .NET languages like C#, you can only call VBScript or JScript extension functions) or like XslCompiledTransform. I don't know which XSLT processors you can use with Stylus Studio but I think by default it uses Saxon and that does not support the Microsoft specific extension to call into C#. So you will need to check whether Stylus Studio allows you to switch to Microsoft's XslCompiledTransform as the XSLT processor.

Parsing XML File with Boost C++

I have to parse one xml file using boost c++, I have written one test code which is working for this xml.
a.xml
<a>
<modules>
<module>abc</module>
<module>def</module>
<module>ghi</module>
</modules>
</a>
Output is coming
abc
def
ghi
but for this a.xml file, my test code is not showing any output, 3 blank lines are coming as output.
<a>
<modules>
<module value = "abc"/>
<module value = "def"/>
<module value = "abc"/>
</modules>
</a>
here is the test code:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <iostream>
int main()
{
using boost::property_tree::ptree;
ptree pt;
read_xml("a.xml",pt);
BOOST_FOREACH(ptree::value_type &v, pt.get_child("a.modules"))
std::cout<<v.second.data()<<std::endl;
return 0;
}
My Problem is I am having a large xml file which contains the mixture of patterns from both the files and I have to parse it.
File is b.xml and I have to get message subtag from each tag.
<MultiMessage>
<Message structID="1710" msgID="0" length="50">
<structure type="AppHeader">
</structure>
</Message>
<Message structID="27057" msgID="27266" length="315">
<structure type="Container">
<productID value="166"/>
<publishTo value="xyz"/>
<templateID value="97845"/>
<sendingTime value="1421320622367060444"/>
<message value="092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK"/>
</structure>
</Message>
</MultiMessage>
<MultiMessage>
<Message structID="1710" msgID="0" length="50">
<structure type="AppHeader">
</structure>
</Message>
<Message structID="27057" msgID="27266" length="315">
<structure type="Container">
<productID value="166"/>
<publishTo value="xyz"/>
<templateID value="97845"/>
<sendingTime value="1421320622367060444"/>
<message value="092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK"/>
</structure>
</Message>
</MultiMessage>
<MultiMessage>
<Message structID="1710" msgID="0" length="50">
<structure type="AppHeader">
</structure>
</Message>
<Message structID="27057" msgID="27266" length="315">
<structure type="Container">
<productID value="166"/>
<publishTo value="xyz"/>
<templateID value="97845"/>
<sendingTime value="1421320622367060444"/>
<message value="092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK"/>
</structure>
</Message>
</MultiMessage>
and output should be :
092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK
092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK
092374NMKLA90U345N09832LJKN0A9845JHKLASDF09U8426LJAKLJDGF09845U6KLJSDGP89U45LJSDFP9GU4569078LJK
Thank You
Regards
Boost Documentation:
The attributes of an XML element are stored in the subkey . There is one child node per attribute in the attribute node. Existence of the node is not guaranteed or necessary when there are no attributes.
<module value = "abc"/>
//One way would be this:
boost::get<std::string>("module.<xmlattr>.value");
One more way (untested), which appears to be better:
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("a.modules"))
{
std::cout << v.second.get_child("<xmlattr>.type").data() << std::endl;
std::cout << v.second.get_child("<xmlattr>.Reference").data() << std::endl;
}
One more taken from here.
//Parse XML...
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("a.modules"))
{
const boost::property_tree::ptree &attributes = v.second.get_child("<xmlattr>", boost::property_tree::ptree());
BOOST_FOREACH(const boost::property_tree::ptree::value_type &v, attributes)
{
std::cout << v.first.data() << std::endl;
std::cout << v.second.data() << std::endl;
}
}