Create an Envelope of the following XML












0















I am struggling with this situations for a while!! and i really hope i can get some help from you.



in a method i am receiving this XML as a string :



<?xml version="1.0" encoding="utf-16" standalone="no"?>
<VC_001_CreateDocument>
<VCRequest>
<Header>
<OrganisationData>
<ClientId />
<UserId />
<Pass />
</OrganisationData>
<Article>
<OutcomeSource>ERP</OutcomeSource>
<ArticleNumber>6034967-Sample</ArticleNumber>
<ProductNumbers>
<ProductNumber Type="GTIN" Level="PRI" />
</ProductNumbers>
<Forecast />
<ERPStatus>APP</ERPStatus>
<SerialisationFlag />
<CSDBArticleNumber>6034967-Sample</CSDBArticleNumber>
<ArticleDescription>Rose</ArticleDescription>
<WorkflowId />
<CommonName />
<PharmaceuticalForm />
<Strength />
<PackageWeight />
<PackageSize />
<PackageType />
<GS1GLN />
<GS1CompanyPrefix />
<Customer>
<CustomerId />
<CustomerErpNumber />
</Customer>
<ShelfLife />
<Region />
<ProductionSites>
<ProductionSite>
<ProductionSiteId />
<ProductionSiteErpNumber />
</ProductionSite>
</ProductionSites>
<GenericArticleField01 />
<GenericArticleField02 />
<GenericArticleField03 />
<GenericArticleField04 />
<GenericArticleField05 />
<RequiredFields>
<RequiredField Name="" />
</RequiredFields>
<Comment />
<Checked />
<TargetMarkets>
<TargetMarket>
<GS1NHRN />
<GenericFields Type="" Language="" />
<Mah />
<Wholesaler />
</TargetMarket>
</TargetMarkets>
<VerificationSystem />
<Email />
<FixData />
<StartValueInitial />
<SubPools>
<SubPool>
<AggregationLevel />
<PoolIdentProductNumber />
<QuantityPerLevel />
<IncompletePackagingRule />
<QuantityOfLayer />
<GenerationPattern />
<PostProductionSerialNumberAssignment />
<PrePrinting />
<Factor />
<Threshold />
<SerialNumberType />
<ExtensionDigit />
<SerialNumberSource />
<DeliveranceInformation>
<MinimumValue />
<PercentualAmount />
</DeliveranceInformation>
</SubPool>
</SubPools>
<Report>
<ReportExternal />
<ReportVerificationSystem />
</Report>
</Article>
</Header>
</VCRequest>
</VC_001_CreateDocument>


to transform in an Envelope to use in my SOAP Request exactly like this: reading the node values of course if they have!



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">
<soapenv:Header/>
<soapenv:Body>
<csdb:VC_001_CreateDocument>
<csdb:VARequest>
<csdb:Header>
<csdb:OrganisationData>
<csdb:ClientId>EDP</csdb:ClientId>
<csdb:UserId>webservice</csdb:UserId>
<csdb:Pass>!password*</csdb:Pass>
</csdb:OrganisationData>
</csdb:Header>
<csdb:Article>
<csdb:OutcomeSource>ERP</csdb:OutcomeSource>
<csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber>
<csdb:ProductNumbers>
<csdb:ProductNumber type="GTIN" level="PRI"></csdb:ProductNumber>
</csdb:ProductNumbers>
<csdb:Forecast></csdb:Forecast>
<csdb:ERPStatus></csdb:ERPStatus>
<csdb:SerialisationFlag></csdb:SerialisationFlag>
<csdb:CSDBArticleNumber>6034967-AMOSTRA</csdb:CSDBArticleNumber>
<csdb:ArticleDescription>PINOX ROSA</csdb:ArticleDescription>
<csdb:WorkflowId></csdb:WorkflowId>
<csdb:CommonName></csdb:CommonName>
<csdb:PharmaceuticalForm></csdb:PharmaceuticalForm>
<csdb:Strength></csdb:Strength>
<csdb:PackageWeight></csdb:PackageWeight>
<csdb:PackageSize></csdb:PackageSize>
<csdb:PackageType></csdb:PackageType>
<csdb:GS1GLN></csdb:GS1GLN>
<csdb:GS1CompanyPrefix></csdb:GS1CompanyPrefix>
<csdb:Customer>
<csdb:Customer></csdb:Customer>
<csdb:CustomerId></csdb:CustomerId>
<csdb:CustomerErpNumber></csdb:CustomerErpNumber>
</csdb:Customer>>
<csdb:ShelfLife></csdb:ShelfLife>
<csdb:Region></csdb:Region>
<csdb:ProductionSites>
<csdb:ProductionSite>
<csdb:ProductionSiteId></csdb:ProductionSiteId>
<csdb:ProductionSiteErpNumber></csdb:ProductionSiteErpNumber>
</csdb:ProductionSite>
</csdb:ProductionSites>
<csdb:GenericArticleField01></csdb:GenericArticleField01>
<csdb:GenericArticleField02></csdb:GenericArticleField02>
<csdb:GenericArticleField03></csdb:GenericArticleField03>
<csdb:GenericArticleField04></csdb:GenericArticleField04>
<csdb:GenericArticleField05></csdb:GenericArticleField05>
<csdb:RequiredFields>
<csdb:RequiredField name="?"></csdb:RequiredField>
</csdb:RequiredFields>
<csdb:Comment></csdb:Comment>
<csdb:Checked></csdb:Checked>
<csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
<csdb:TargetMarkets>
<csdb:TargetMarket targetMarket="?">
<csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
<csdb:GenericFields type="?" language="?"></csdb:GenericFields>
<csdb:Mah></csdb:Mah>
<csdb:Wholesaler></csdb:Wholesaler>
</csdb:TargetMarket>
</csdb:TargetMarkets>
<csdb:Verificationsystem></csdb:Verificationsystem>
<csdb:Email></csdb:Email>
<csdb:FixData></csdb:FixData>
<csdb:StartValueInitial></csdb:StartValueInitial>
<csdb:Subpools>
<csdb:Subpool>
<csdb:AggregationLevel></csdb:AggregationLevel>
<csdb:PoolIdentProductNumber type="?"></csdb:PoolIdentProductNumber>
<csdb:QuantityPerLevel></csdb:QuantityPerLevel>
<csdb:IncompletePackagingRule></csdb:IncompletePackagingRule>
<csdb:QuantityOfLayer></csdb:QuantityOfLayer>
<csdb:GenerationPattern></csdb:GenerationPattern>
<csdb:PostProductionSerialNumberAssignment></csdb:PostProductionSerialNumberAssignment>
<csdb:PrePrinting></csdb:PrePrinting>
<csdb:Factor></csdb:Factor>
<csdb:Threshold></csdb:Threshold>
<csdb:SerialNumberType></csdb:SerialNumberType>
<csdb:ExtensionDigit></csdb:ExtensionDigit>
<csdb:SerialNumberSource></csdb:SerialNumberSource>
<csdb:DeliveranceInformation>
<csdb:MinimumValue></csdb:MinimumValue>
<csdb:PercentualAmount></csdb:PercentualAmount>
</csdb:DeliveranceInformation>
</csdb:Subpool>
</csdb:Subpools>
<csdb:Report>
<csdb:ReportExternal></csdb:ReportExternal>
<csdb:ReportVerificationSystem></csdb:ReportVerificationSystem>
</csdb:Report>
</csdb:Article>
</csdb:VCRequest>
</csdb:VC_001_CreateDocument>
</soapenv:Body>
</soapenv:Envelope>


THis is exactly the XML that i receive and that's the envelope that i will have to create (Request generated by SOAPUI),the nodes will have dynamic Values of course, those parameteres were just an example.
i assume this is the easiest way since i can't "add service reference" because i am trying to develop a DLL where the webservices will be nested. There's no web.config where this DLL is going to be installed.
Thank you soo much for helping me with the logic for this problem that is driving me crazy










share|improve this question





























    0















    I am struggling with this situations for a while!! and i really hope i can get some help from you.



    in a method i am receiving this XML as a string :



    <?xml version="1.0" encoding="utf-16" standalone="no"?>
    <VC_001_CreateDocument>
    <VCRequest>
    <Header>
    <OrganisationData>
    <ClientId />
    <UserId />
    <Pass />
    </OrganisationData>
    <Article>
    <OutcomeSource>ERP</OutcomeSource>
    <ArticleNumber>6034967-Sample</ArticleNumber>
    <ProductNumbers>
    <ProductNumber Type="GTIN" Level="PRI" />
    </ProductNumbers>
    <Forecast />
    <ERPStatus>APP</ERPStatus>
    <SerialisationFlag />
    <CSDBArticleNumber>6034967-Sample</CSDBArticleNumber>
    <ArticleDescription>Rose</ArticleDescription>
    <WorkflowId />
    <CommonName />
    <PharmaceuticalForm />
    <Strength />
    <PackageWeight />
    <PackageSize />
    <PackageType />
    <GS1GLN />
    <GS1CompanyPrefix />
    <Customer>
    <CustomerId />
    <CustomerErpNumber />
    </Customer>
    <ShelfLife />
    <Region />
    <ProductionSites>
    <ProductionSite>
    <ProductionSiteId />
    <ProductionSiteErpNumber />
    </ProductionSite>
    </ProductionSites>
    <GenericArticleField01 />
    <GenericArticleField02 />
    <GenericArticleField03 />
    <GenericArticleField04 />
    <GenericArticleField05 />
    <RequiredFields>
    <RequiredField Name="" />
    </RequiredFields>
    <Comment />
    <Checked />
    <TargetMarkets>
    <TargetMarket>
    <GS1NHRN />
    <GenericFields Type="" Language="" />
    <Mah />
    <Wholesaler />
    </TargetMarket>
    </TargetMarkets>
    <VerificationSystem />
    <Email />
    <FixData />
    <StartValueInitial />
    <SubPools>
    <SubPool>
    <AggregationLevel />
    <PoolIdentProductNumber />
    <QuantityPerLevel />
    <IncompletePackagingRule />
    <QuantityOfLayer />
    <GenerationPattern />
    <PostProductionSerialNumberAssignment />
    <PrePrinting />
    <Factor />
    <Threshold />
    <SerialNumberType />
    <ExtensionDigit />
    <SerialNumberSource />
    <DeliveranceInformation>
    <MinimumValue />
    <PercentualAmount />
    </DeliveranceInformation>
    </SubPool>
    </SubPools>
    <Report>
    <ReportExternal />
    <ReportVerificationSystem />
    </Report>
    </Article>
    </Header>
    </VCRequest>
    </VC_001_CreateDocument>


    to transform in an Envelope to use in my SOAP Request exactly like this: reading the node values of course if they have!



    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">
    <soapenv:Header/>
    <soapenv:Body>
    <csdb:VC_001_CreateDocument>
    <csdb:VARequest>
    <csdb:Header>
    <csdb:OrganisationData>
    <csdb:ClientId>EDP</csdb:ClientId>
    <csdb:UserId>webservice</csdb:UserId>
    <csdb:Pass>!password*</csdb:Pass>
    </csdb:OrganisationData>
    </csdb:Header>
    <csdb:Article>
    <csdb:OutcomeSource>ERP</csdb:OutcomeSource>
    <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber>
    <csdb:ProductNumbers>
    <csdb:ProductNumber type="GTIN" level="PRI"></csdb:ProductNumber>
    </csdb:ProductNumbers>
    <csdb:Forecast></csdb:Forecast>
    <csdb:ERPStatus></csdb:ERPStatus>
    <csdb:SerialisationFlag></csdb:SerialisationFlag>
    <csdb:CSDBArticleNumber>6034967-AMOSTRA</csdb:CSDBArticleNumber>
    <csdb:ArticleDescription>PINOX ROSA</csdb:ArticleDescription>
    <csdb:WorkflowId></csdb:WorkflowId>
    <csdb:CommonName></csdb:CommonName>
    <csdb:PharmaceuticalForm></csdb:PharmaceuticalForm>
    <csdb:Strength></csdb:Strength>
    <csdb:PackageWeight></csdb:PackageWeight>
    <csdb:PackageSize></csdb:PackageSize>
    <csdb:PackageType></csdb:PackageType>
    <csdb:GS1GLN></csdb:GS1GLN>
    <csdb:GS1CompanyPrefix></csdb:GS1CompanyPrefix>
    <csdb:Customer>
    <csdb:Customer></csdb:Customer>
    <csdb:CustomerId></csdb:CustomerId>
    <csdb:CustomerErpNumber></csdb:CustomerErpNumber>
    </csdb:Customer>>
    <csdb:ShelfLife></csdb:ShelfLife>
    <csdb:Region></csdb:Region>
    <csdb:ProductionSites>
    <csdb:ProductionSite>
    <csdb:ProductionSiteId></csdb:ProductionSiteId>
    <csdb:ProductionSiteErpNumber></csdb:ProductionSiteErpNumber>
    </csdb:ProductionSite>
    </csdb:ProductionSites>
    <csdb:GenericArticleField01></csdb:GenericArticleField01>
    <csdb:GenericArticleField02></csdb:GenericArticleField02>
    <csdb:GenericArticleField03></csdb:GenericArticleField03>
    <csdb:GenericArticleField04></csdb:GenericArticleField04>
    <csdb:GenericArticleField05></csdb:GenericArticleField05>
    <csdb:RequiredFields>
    <csdb:RequiredField name="?"></csdb:RequiredField>
    </csdb:RequiredFields>
    <csdb:Comment></csdb:Comment>
    <csdb:Checked></csdb:Checked>
    <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
    <csdb:TargetMarkets>
    <csdb:TargetMarket targetMarket="?">
    <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
    <csdb:GenericFields type="?" language="?"></csdb:GenericFields>
    <csdb:Mah></csdb:Mah>
    <csdb:Wholesaler></csdb:Wholesaler>
    </csdb:TargetMarket>
    </csdb:TargetMarkets>
    <csdb:Verificationsystem></csdb:Verificationsystem>
    <csdb:Email></csdb:Email>
    <csdb:FixData></csdb:FixData>
    <csdb:StartValueInitial></csdb:StartValueInitial>
    <csdb:Subpools>
    <csdb:Subpool>
    <csdb:AggregationLevel></csdb:AggregationLevel>
    <csdb:PoolIdentProductNumber type="?"></csdb:PoolIdentProductNumber>
    <csdb:QuantityPerLevel></csdb:QuantityPerLevel>
    <csdb:IncompletePackagingRule></csdb:IncompletePackagingRule>
    <csdb:QuantityOfLayer></csdb:QuantityOfLayer>
    <csdb:GenerationPattern></csdb:GenerationPattern>
    <csdb:PostProductionSerialNumberAssignment></csdb:PostProductionSerialNumberAssignment>
    <csdb:PrePrinting></csdb:PrePrinting>
    <csdb:Factor></csdb:Factor>
    <csdb:Threshold></csdb:Threshold>
    <csdb:SerialNumberType></csdb:SerialNumberType>
    <csdb:ExtensionDigit></csdb:ExtensionDigit>
    <csdb:SerialNumberSource></csdb:SerialNumberSource>
    <csdb:DeliveranceInformation>
    <csdb:MinimumValue></csdb:MinimumValue>
    <csdb:PercentualAmount></csdb:PercentualAmount>
    </csdb:DeliveranceInformation>
    </csdb:Subpool>
    </csdb:Subpools>
    <csdb:Report>
    <csdb:ReportExternal></csdb:ReportExternal>
    <csdb:ReportVerificationSystem></csdb:ReportVerificationSystem>
    </csdb:Report>
    </csdb:Article>
    </csdb:VCRequest>
    </csdb:VC_001_CreateDocument>
    </soapenv:Body>
    </soapenv:Envelope>


    THis is exactly the XML that i receive and that's the envelope that i will have to create (Request generated by SOAPUI),the nodes will have dynamic Values of course, those parameteres were just an example.
    i assume this is the easiest way since i can't "add service reference" because i am trying to develop a DLL where the webservices will be nested. There's no web.config where this DLL is going to be installed.
    Thank you soo much for helping me with the logic for this problem that is driving me crazy










    share|improve this question



























      0












      0








      0








      I am struggling with this situations for a while!! and i really hope i can get some help from you.



      in a method i am receiving this XML as a string :



      <?xml version="1.0" encoding="utf-16" standalone="no"?>
      <VC_001_CreateDocument>
      <VCRequest>
      <Header>
      <OrganisationData>
      <ClientId />
      <UserId />
      <Pass />
      </OrganisationData>
      <Article>
      <OutcomeSource>ERP</OutcomeSource>
      <ArticleNumber>6034967-Sample</ArticleNumber>
      <ProductNumbers>
      <ProductNumber Type="GTIN" Level="PRI" />
      </ProductNumbers>
      <Forecast />
      <ERPStatus>APP</ERPStatus>
      <SerialisationFlag />
      <CSDBArticleNumber>6034967-Sample</CSDBArticleNumber>
      <ArticleDescription>Rose</ArticleDescription>
      <WorkflowId />
      <CommonName />
      <PharmaceuticalForm />
      <Strength />
      <PackageWeight />
      <PackageSize />
      <PackageType />
      <GS1GLN />
      <GS1CompanyPrefix />
      <Customer>
      <CustomerId />
      <CustomerErpNumber />
      </Customer>
      <ShelfLife />
      <Region />
      <ProductionSites>
      <ProductionSite>
      <ProductionSiteId />
      <ProductionSiteErpNumber />
      </ProductionSite>
      </ProductionSites>
      <GenericArticleField01 />
      <GenericArticleField02 />
      <GenericArticleField03 />
      <GenericArticleField04 />
      <GenericArticleField05 />
      <RequiredFields>
      <RequiredField Name="" />
      </RequiredFields>
      <Comment />
      <Checked />
      <TargetMarkets>
      <TargetMarket>
      <GS1NHRN />
      <GenericFields Type="" Language="" />
      <Mah />
      <Wholesaler />
      </TargetMarket>
      </TargetMarkets>
      <VerificationSystem />
      <Email />
      <FixData />
      <StartValueInitial />
      <SubPools>
      <SubPool>
      <AggregationLevel />
      <PoolIdentProductNumber />
      <QuantityPerLevel />
      <IncompletePackagingRule />
      <QuantityOfLayer />
      <GenerationPattern />
      <PostProductionSerialNumberAssignment />
      <PrePrinting />
      <Factor />
      <Threshold />
      <SerialNumberType />
      <ExtensionDigit />
      <SerialNumberSource />
      <DeliveranceInformation>
      <MinimumValue />
      <PercentualAmount />
      </DeliveranceInformation>
      </SubPool>
      </SubPools>
      <Report>
      <ReportExternal />
      <ReportVerificationSystem />
      </Report>
      </Article>
      </Header>
      </VCRequest>
      </VC_001_CreateDocument>


      to transform in an Envelope to use in my SOAP Request exactly like this: reading the node values of course if they have!



      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">
      <soapenv:Header/>
      <soapenv:Body>
      <csdb:VC_001_CreateDocument>
      <csdb:VARequest>
      <csdb:Header>
      <csdb:OrganisationData>
      <csdb:ClientId>EDP</csdb:ClientId>
      <csdb:UserId>webservice</csdb:UserId>
      <csdb:Pass>!password*</csdb:Pass>
      </csdb:OrganisationData>
      </csdb:Header>
      <csdb:Article>
      <csdb:OutcomeSource>ERP</csdb:OutcomeSource>
      <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber>
      <csdb:ProductNumbers>
      <csdb:ProductNumber type="GTIN" level="PRI"></csdb:ProductNumber>
      </csdb:ProductNumbers>
      <csdb:Forecast></csdb:Forecast>
      <csdb:ERPStatus></csdb:ERPStatus>
      <csdb:SerialisationFlag></csdb:SerialisationFlag>
      <csdb:CSDBArticleNumber>6034967-AMOSTRA</csdb:CSDBArticleNumber>
      <csdb:ArticleDescription>PINOX ROSA</csdb:ArticleDescription>
      <csdb:WorkflowId></csdb:WorkflowId>
      <csdb:CommonName></csdb:CommonName>
      <csdb:PharmaceuticalForm></csdb:PharmaceuticalForm>
      <csdb:Strength></csdb:Strength>
      <csdb:PackageWeight></csdb:PackageWeight>
      <csdb:PackageSize></csdb:PackageSize>
      <csdb:PackageType></csdb:PackageType>
      <csdb:GS1GLN></csdb:GS1GLN>
      <csdb:GS1CompanyPrefix></csdb:GS1CompanyPrefix>
      <csdb:Customer>
      <csdb:Customer></csdb:Customer>
      <csdb:CustomerId></csdb:CustomerId>
      <csdb:CustomerErpNumber></csdb:CustomerErpNumber>
      </csdb:Customer>>
      <csdb:ShelfLife></csdb:ShelfLife>
      <csdb:Region></csdb:Region>
      <csdb:ProductionSites>
      <csdb:ProductionSite>
      <csdb:ProductionSiteId></csdb:ProductionSiteId>
      <csdb:ProductionSiteErpNumber></csdb:ProductionSiteErpNumber>
      </csdb:ProductionSite>
      </csdb:ProductionSites>
      <csdb:GenericArticleField01></csdb:GenericArticleField01>
      <csdb:GenericArticleField02></csdb:GenericArticleField02>
      <csdb:GenericArticleField03></csdb:GenericArticleField03>
      <csdb:GenericArticleField04></csdb:GenericArticleField04>
      <csdb:GenericArticleField05></csdb:GenericArticleField05>
      <csdb:RequiredFields>
      <csdb:RequiredField name="?"></csdb:RequiredField>
      </csdb:RequiredFields>
      <csdb:Comment></csdb:Comment>
      <csdb:Checked></csdb:Checked>
      <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
      <csdb:TargetMarkets>
      <csdb:TargetMarket targetMarket="?">
      <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
      <csdb:GenericFields type="?" language="?"></csdb:GenericFields>
      <csdb:Mah></csdb:Mah>
      <csdb:Wholesaler></csdb:Wholesaler>
      </csdb:TargetMarket>
      </csdb:TargetMarkets>
      <csdb:Verificationsystem></csdb:Verificationsystem>
      <csdb:Email></csdb:Email>
      <csdb:FixData></csdb:FixData>
      <csdb:StartValueInitial></csdb:StartValueInitial>
      <csdb:Subpools>
      <csdb:Subpool>
      <csdb:AggregationLevel></csdb:AggregationLevel>
      <csdb:PoolIdentProductNumber type="?"></csdb:PoolIdentProductNumber>
      <csdb:QuantityPerLevel></csdb:QuantityPerLevel>
      <csdb:IncompletePackagingRule></csdb:IncompletePackagingRule>
      <csdb:QuantityOfLayer></csdb:QuantityOfLayer>
      <csdb:GenerationPattern></csdb:GenerationPattern>
      <csdb:PostProductionSerialNumberAssignment></csdb:PostProductionSerialNumberAssignment>
      <csdb:PrePrinting></csdb:PrePrinting>
      <csdb:Factor></csdb:Factor>
      <csdb:Threshold></csdb:Threshold>
      <csdb:SerialNumberType></csdb:SerialNumberType>
      <csdb:ExtensionDigit></csdb:ExtensionDigit>
      <csdb:SerialNumberSource></csdb:SerialNumberSource>
      <csdb:DeliveranceInformation>
      <csdb:MinimumValue></csdb:MinimumValue>
      <csdb:PercentualAmount></csdb:PercentualAmount>
      </csdb:DeliveranceInformation>
      </csdb:Subpool>
      </csdb:Subpools>
      <csdb:Report>
      <csdb:ReportExternal></csdb:ReportExternal>
      <csdb:ReportVerificationSystem></csdb:ReportVerificationSystem>
      </csdb:Report>
      </csdb:Article>
      </csdb:VCRequest>
      </csdb:VC_001_CreateDocument>
      </soapenv:Body>
      </soapenv:Envelope>


      THis is exactly the XML that i receive and that's the envelope that i will have to create (Request generated by SOAPUI),the nodes will have dynamic Values of course, those parameteres were just an example.
      i assume this is the easiest way since i can't "add service reference" because i am trying to develop a DLL where the webservices will be nested. There's no web.config where this DLL is going to be installed.
      Thank you soo much for helping me with the logic for this problem that is driving me crazy










      share|improve this question
















      I am struggling with this situations for a while!! and i really hope i can get some help from you.



      in a method i am receiving this XML as a string :



      <?xml version="1.0" encoding="utf-16" standalone="no"?>
      <VC_001_CreateDocument>
      <VCRequest>
      <Header>
      <OrganisationData>
      <ClientId />
      <UserId />
      <Pass />
      </OrganisationData>
      <Article>
      <OutcomeSource>ERP</OutcomeSource>
      <ArticleNumber>6034967-Sample</ArticleNumber>
      <ProductNumbers>
      <ProductNumber Type="GTIN" Level="PRI" />
      </ProductNumbers>
      <Forecast />
      <ERPStatus>APP</ERPStatus>
      <SerialisationFlag />
      <CSDBArticleNumber>6034967-Sample</CSDBArticleNumber>
      <ArticleDescription>Rose</ArticleDescription>
      <WorkflowId />
      <CommonName />
      <PharmaceuticalForm />
      <Strength />
      <PackageWeight />
      <PackageSize />
      <PackageType />
      <GS1GLN />
      <GS1CompanyPrefix />
      <Customer>
      <CustomerId />
      <CustomerErpNumber />
      </Customer>
      <ShelfLife />
      <Region />
      <ProductionSites>
      <ProductionSite>
      <ProductionSiteId />
      <ProductionSiteErpNumber />
      </ProductionSite>
      </ProductionSites>
      <GenericArticleField01 />
      <GenericArticleField02 />
      <GenericArticleField03 />
      <GenericArticleField04 />
      <GenericArticleField05 />
      <RequiredFields>
      <RequiredField Name="" />
      </RequiredFields>
      <Comment />
      <Checked />
      <TargetMarkets>
      <TargetMarket>
      <GS1NHRN />
      <GenericFields Type="" Language="" />
      <Mah />
      <Wholesaler />
      </TargetMarket>
      </TargetMarkets>
      <VerificationSystem />
      <Email />
      <FixData />
      <StartValueInitial />
      <SubPools>
      <SubPool>
      <AggregationLevel />
      <PoolIdentProductNumber />
      <QuantityPerLevel />
      <IncompletePackagingRule />
      <QuantityOfLayer />
      <GenerationPattern />
      <PostProductionSerialNumberAssignment />
      <PrePrinting />
      <Factor />
      <Threshold />
      <SerialNumberType />
      <ExtensionDigit />
      <SerialNumberSource />
      <DeliveranceInformation>
      <MinimumValue />
      <PercentualAmount />
      </DeliveranceInformation>
      </SubPool>
      </SubPools>
      <Report>
      <ReportExternal />
      <ReportVerificationSystem />
      </Report>
      </Article>
      </Header>
      </VCRequest>
      </VC_001_CreateDocument>


      to transform in an Envelope to use in my SOAP Request exactly like this: reading the node values of course if they have!



      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">
      <soapenv:Header/>
      <soapenv:Body>
      <csdb:VC_001_CreateDocument>
      <csdb:VARequest>
      <csdb:Header>
      <csdb:OrganisationData>
      <csdb:ClientId>EDP</csdb:ClientId>
      <csdb:UserId>webservice</csdb:UserId>
      <csdb:Pass>!password*</csdb:Pass>
      </csdb:OrganisationData>
      </csdb:Header>
      <csdb:Article>
      <csdb:OutcomeSource>ERP</csdb:OutcomeSource>
      <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber>
      <csdb:ProductNumbers>
      <csdb:ProductNumber type="GTIN" level="PRI"></csdb:ProductNumber>
      </csdb:ProductNumbers>
      <csdb:Forecast></csdb:Forecast>
      <csdb:ERPStatus></csdb:ERPStatus>
      <csdb:SerialisationFlag></csdb:SerialisationFlag>
      <csdb:CSDBArticleNumber>6034967-AMOSTRA</csdb:CSDBArticleNumber>
      <csdb:ArticleDescription>PINOX ROSA</csdb:ArticleDescription>
      <csdb:WorkflowId></csdb:WorkflowId>
      <csdb:CommonName></csdb:CommonName>
      <csdb:PharmaceuticalForm></csdb:PharmaceuticalForm>
      <csdb:Strength></csdb:Strength>
      <csdb:PackageWeight></csdb:PackageWeight>
      <csdb:PackageSize></csdb:PackageSize>
      <csdb:PackageType></csdb:PackageType>
      <csdb:GS1GLN></csdb:GS1GLN>
      <csdb:GS1CompanyPrefix></csdb:GS1CompanyPrefix>
      <csdb:Customer>
      <csdb:Customer></csdb:Customer>
      <csdb:CustomerId></csdb:CustomerId>
      <csdb:CustomerErpNumber></csdb:CustomerErpNumber>
      </csdb:Customer>>
      <csdb:ShelfLife></csdb:ShelfLife>
      <csdb:Region></csdb:Region>
      <csdb:ProductionSites>
      <csdb:ProductionSite>
      <csdb:ProductionSiteId></csdb:ProductionSiteId>
      <csdb:ProductionSiteErpNumber></csdb:ProductionSiteErpNumber>
      </csdb:ProductionSite>
      </csdb:ProductionSites>
      <csdb:GenericArticleField01></csdb:GenericArticleField01>
      <csdb:GenericArticleField02></csdb:GenericArticleField02>
      <csdb:GenericArticleField03></csdb:GenericArticleField03>
      <csdb:GenericArticleField04></csdb:GenericArticleField04>
      <csdb:GenericArticleField05></csdb:GenericArticleField05>
      <csdb:RequiredFields>
      <csdb:RequiredField name="?"></csdb:RequiredField>
      </csdb:RequiredFields>
      <csdb:Comment></csdb:Comment>
      <csdb:Checked></csdb:Checked>
      <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
      <csdb:TargetMarkets>
      <csdb:TargetMarket targetMarket="?">
      <csdb:GS1NHRN GS1NHRNNational="?"></csdb:GS1NHRN>
      <csdb:GenericFields type="?" language="?"></csdb:GenericFields>
      <csdb:Mah></csdb:Mah>
      <csdb:Wholesaler></csdb:Wholesaler>
      </csdb:TargetMarket>
      </csdb:TargetMarkets>
      <csdb:Verificationsystem></csdb:Verificationsystem>
      <csdb:Email></csdb:Email>
      <csdb:FixData></csdb:FixData>
      <csdb:StartValueInitial></csdb:StartValueInitial>
      <csdb:Subpools>
      <csdb:Subpool>
      <csdb:AggregationLevel></csdb:AggregationLevel>
      <csdb:PoolIdentProductNumber type="?"></csdb:PoolIdentProductNumber>
      <csdb:QuantityPerLevel></csdb:QuantityPerLevel>
      <csdb:IncompletePackagingRule></csdb:IncompletePackagingRule>
      <csdb:QuantityOfLayer></csdb:QuantityOfLayer>
      <csdb:GenerationPattern></csdb:GenerationPattern>
      <csdb:PostProductionSerialNumberAssignment></csdb:PostProductionSerialNumberAssignment>
      <csdb:PrePrinting></csdb:PrePrinting>
      <csdb:Factor></csdb:Factor>
      <csdb:Threshold></csdb:Threshold>
      <csdb:SerialNumberType></csdb:SerialNumberType>
      <csdb:ExtensionDigit></csdb:ExtensionDigit>
      <csdb:SerialNumberSource></csdb:SerialNumberSource>
      <csdb:DeliveranceInformation>
      <csdb:MinimumValue></csdb:MinimumValue>
      <csdb:PercentualAmount></csdb:PercentualAmount>
      </csdb:DeliveranceInformation>
      </csdb:Subpool>
      </csdb:Subpools>
      <csdb:Report>
      <csdb:ReportExternal></csdb:ReportExternal>
      <csdb:ReportVerificationSystem></csdb:ReportVerificationSystem>
      </csdb:Report>
      </csdb:Article>
      </csdb:VCRequest>
      </csdb:VC_001_CreateDocument>
      </soapenv:Body>
      </soapenv:Envelope>


      THis is exactly the XML that i receive and that's the envelope that i will have to create (Request generated by SOAPUI),the nodes will have dynamic Values of course, those parameteres were just an example.
      i assume this is the easiest way since i can't "add service reference" because i am trying to develop a DLL where the webservices will be nested. There's no web.config where this DLL is going to be installed.
      Thank you soo much for helping me with the logic for this problem that is driving me crazy







      c# .net xml linq-to-xml xmldocument






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 23:27







      JohnnyJoe

















      asked Nov 21 '18 at 22:11









      JohnnyJoeJohnnyJoe

      12




      12
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Using xml linq :



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Xml;
          using System.Xml.Linq;
          using System.IO;

          namespace ConsoleApplication1
          {
          class Program
          {
          const string FILENAME = @"c:temptest.xml";
          static void Main(string args)
          {
          StreamReader reader = new StreamReader(FILENAME);
          reader.ReadLine(); // skip the utf-16 in header that Net Library doesn't accept
          XDocument doc = XDocument.Load(reader);

          string soapHeader = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>";

          XElement soap = XElement.Parse(soapHeader);
          XNamespace nsCsdb = soap.GetNamespaceOfPrefix("csdb");
          XNamespace nsSoapenv = soap.GetNamespaceOfPrefix("soapenv");
          XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault();

          body.Add(doc.Root);
          foreach (XElement child in body.Descendants())
          {
          child.Name = nsCsdb.GetName(child.Name.LocalName);
          List<XAttribute> atList = child.Attributes().ToList();
          child.Attributes().Remove();
          foreach (XAttribute at in atList)
          child.Add(new XAttribute(nsCsdb.GetName(at.Name.LocalName), at.Value));
          }
          }
          }
          }





          share|improve this answer
























          • Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

            – JohnnyJoe
            Nov 22 '18 at 9:42













          • doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

            – jdweng
            Nov 22 '18 at 11:38











          • How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

            – JohnnyJoe
            Nov 22 '18 at 14:17











          • I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

            – jdweng
            Nov 22 '18 at 14:43











          • Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

            – JohnnyJoe
            Nov 22 '18 at 14:53











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421155%2fcreate-an-envelope-of-the-following-xml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Using xml linq :



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Xml;
          using System.Xml.Linq;
          using System.IO;

          namespace ConsoleApplication1
          {
          class Program
          {
          const string FILENAME = @"c:temptest.xml";
          static void Main(string args)
          {
          StreamReader reader = new StreamReader(FILENAME);
          reader.ReadLine(); // skip the utf-16 in header that Net Library doesn't accept
          XDocument doc = XDocument.Load(reader);

          string soapHeader = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>";

          XElement soap = XElement.Parse(soapHeader);
          XNamespace nsCsdb = soap.GetNamespaceOfPrefix("csdb");
          XNamespace nsSoapenv = soap.GetNamespaceOfPrefix("soapenv");
          XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault();

          body.Add(doc.Root);
          foreach (XElement child in body.Descendants())
          {
          child.Name = nsCsdb.GetName(child.Name.LocalName);
          List<XAttribute> atList = child.Attributes().ToList();
          child.Attributes().Remove();
          foreach (XAttribute at in atList)
          child.Add(new XAttribute(nsCsdb.GetName(at.Name.LocalName), at.Value));
          }
          }
          }
          }





          share|improve this answer
























          • Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

            – JohnnyJoe
            Nov 22 '18 at 9:42













          • doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

            – jdweng
            Nov 22 '18 at 11:38











          • How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

            – JohnnyJoe
            Nov 22 '18 at 14:17











          • I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

            – jdweng
            Nov 22 '18 at 14:43











          • Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

            – JohnnyJoe
            Nov 22 '18 at 14:53
















          0














          Using xml linq :



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Xml;
          using System.Xml.Linq;
          using System.IO;

          namespace ConsoleApplication1
          {
          class Program
          {
          const string FILENAME = @"c:temptest.xml";
          static void Main(string args)
          {
          StreamReader reader = new StreamReader(FILENAME);
          reader.ReadLine(); // skip the utf-16 in header that Net Library doesn't accept
          XDocument doc = XDocument.Load(reader);

          string soapHeader = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>";

          XElement soap = XElement.Parse(soapHeader);
          XNamespace nsCsdb = soap.GetNamespaceOfPrefix("csdb");
          XNamespace nsSoapenv = soap.GetNamespaceOfPrefix("soapenv");
          XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault();

          body.Add(doc.Root);
          foreach (XElement child in body.Descendants())
          {
          child.Name = nsCsdb.GetName(child.Name.LocalName);
          List<XAttribute> atList = child.Attributes().ToList();
          child.Attributes().Remove();
          foreach (XAttribute at in atList)
          child.Add(new XAttribute(nsCsdb.GetName(at.Name.LocalName), at.Value));
          }
          }
          }
          }





          share|improve this answer
























          • Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

            – JohnnyJoe
            Nov 22 '18 at 9:42













          • doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

            – jdweng
            Nov 22 '18 at 11:38











          • How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

            – JohnnyJoe
            Nov 22 '18 at 14:17











          • I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

            – jdweng
            Nov 22 '18 at 14:43











          • Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

            – JohnnyJoe
            Nov 22 '18 at 14:53














          0












          0








          0







          Using xml linq :



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Xml;
          using System.Xml.Linq;
          using System.IO;

          namespace ConsoleApplication1
          {
          class Program
          {
          const string FILENAME = @"c:temptest.xml";
          static void Main(string args)
          {
          StreamReader reader = new StreamReader(FILENAME);
          reader.ReadLine(); // skip the utf-16 in header that Net Library doesn't accept
          XDocument doc = XDocument.Load(reader);

          string soapHeader = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>";

          XElement soap = XElement.Parse(soapHeader);
          XNamespace nsCsdb = soap.GetNamespaceOfPrefix("csdb");
          XNamespace nsSoapenv = soap.GetNamespaceOfPrefix("soapenv");
          XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault();

          body.Add(doc.Root);
          foreach (XElement child in body.Descendants())
          {
          child.Name = nsCsdb.GetName(child.Name.LocalName);
          List<XAttribute> atList = child.Attributes().ToList();
          child.Attributes().Remove();
          foreach (XAttribute at in atList)
          child.Add(new XAttribute(nsCsdb.GetName(at.Name.LocalName), at.Value));
          }
          }
          }
          }





          share|improve this answer













          Using xml linq :



          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using System.Xml;
          using System.Xml.Linq;
          using System.IO;

          namespace ConsoleApplication1
          {
          class Program
          {
          const string FILENAME = @"c:temptest.xml";
          static void Main(string args)
          {
          StreamReader reader = new StreamReader(FILENAME);
          reader.ReadLine(); // skip the utf-16 in header that Net Library doesn't accept
          XDocument doc = XDocument.Load(reader);

          string soapHeader = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:csdb="http://site.de/csdb">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>";

          XElement soap = XElement.Parse(soapHeader);
          XNamespace nsCsdb = soap.GetNamespaceOfPrefix("csdb");
          XNamespace nsSoapenv = soap.GetNamespaceOfPrefix("soapenv");
          XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault();

          body.Add(doc.Root);
          foreach (XElement child in body.Descendants())
          {
          child.Name = nsCsdb.GetName(child.Name.LocalName);
          List<XAttribute> atList = child.Attributes().ToList();
          child.Attributes().Remove();
          foreach (XAttribute at in atList)
          child.Add(new XAttribute(nsCsdb.GetName(at.Name.LocalName), at.Value));
          }
          }
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 23:18









          jdwengjdweng

          17.4k2717




          17.4k2717













          • Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

            – JohnnyJoe
            Nov 22 '18 at 9:42













          • doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

            – jdweng
            Nov 22 '18 at 11:38











          • How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

            – JohnnyJoe
            Nov 22 '18 at 14:17











          • I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

            – jdweng
            Nov 22 '18 at 14:43











          • Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

            – JohnnyJoe
            Nov 22 '18 at 14:53



















          • Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

            – JohnnyJoe
            Nov 22 '18 at 9:42













          • doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

            – jdweng
            Nov 22 '18 at 11:38











          • How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

            – JohnnyJoe
            Nov 22 '18 at 14:17











          • I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

            – jdweng
            Nov 22 '18 at 14:43











          • Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

            – JohnnyJoe
            Nov 22 '18 at 14:53

















          Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

          – JohnnyJoe
          Nov 22 '18 at 9:42







          Hello my friend! this seems to work i will test it asap and i will give you the feedback, but why the body.Add(doc.Root); ?? are u adding the root element to the body? but the root element is not <soapenv:Envelope?. If i want to write that XML to a new folder what line of code should i use? is it possible to create an XML inside my project with the output result? if not in some other folder. In case i receive a String as my XML and i won't be able to execute reader.ReadLine(); // to skip the utf-16 in header that Net Library doesn't accept, how can i skip that line?

          – JohnnyJoe
          Nov 22 '18 at 9:42















          doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

          – jdweng
          Nov 22 '18 at 11:38





          doc is a XDocument and the body.Add needs a XElement. Using doc.Root get the XElement from the XDocument. Not sure I understand all you questions. XElement has a save method : soap.Save(stream). You can use a MemoryStream to use the xml inside you app. Or simply convert to the string : string soapStr = soap.ToString(); When you xml is a string then use StringReader : StringReader reader = new StringReader(xml); reader.ReadLine();

          – jdweng
          Nov 22 '18 at 11:38













          How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

          – JohnnyJoe
          Nov 22 '18 at 14:17





          How are you retrieving the values for the nodes for example...<csdb:OutcomeSource>ERP</csdb:OutcomeSource> or <csdb:ArticleNumber>6034967-Sample</csdb:ArticleNumber> (ERP and 6034967-Sample) ? The other question was in XElement body = soap.Descendants(nsSoapenv + "Body").FirstOrDefault(); can i use something like regex to find all nodes with self closing tag and transform into open and end tag (<tag></tag>) ?

          – JohnnyJoe
          Nov 22 '18 at 14:17













          I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

          – jdweng
          Nov 22 '18 at 14:43





          I'm just inserting the entire xml string into the soap. Then adding the namespace. Never us REGEX on an xml file. Regex is for regular expressions and xml is not regular.

          – jdweng
          Nov 22 '18 at 14:43













          Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

          – JohnnyJoe
          Nov 22 '18 at 14:53





          Ok i got it. and that answered my first Question. but this can be done right? change the tags do generate this envelope? maybe not with Regex...

          – JohnnyJoe
          Nov 22 '18 at 14:53




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421155%2fcreate-an-envelope-of-the-following-xml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

          ts Property 'filter' does not exist on type '{}'

          Notepad++ export/extract a list of installed plugins