Amazon MWS SubmitFeed Updating stock quantity - amazon-web-services

I'm having problems with a stock quantity update feed using Amazon MWS. My Feed is submitted and processed, but I get errors, however if I submit the same XML via the scratchpad, the inventory updates are accepted and processed.
(merchant id starred out deliberately)
Submission and response below:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>************</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>BUS999904</SKU>
<Quantity>269</Quantity>
</Inventory>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>PROBS-HO-01</SKU>
<Quantity>137</Quantity>
</Inventory>
</Message>
And the response:
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.02</DocumentVersion>
<MerchantIdentifier>M_ONTRACKSCO_1106147</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>54774016520</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>2</MessagesProcessed>
<MessagesSuccessful>0</MessagesSuccessful>
<MessagesWithError>2</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>25</ResultMessageCode>
<ResultDescription>We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. </ResultDescription>
</Result>
<Result>
<MessageID>2</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>25</ResultMessageCode>
<ResultDescription>We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed.</ResultDescription>
</Result>
</ProcessingReport>
</Message>
Any help anyone can give, or pointers/examples of valid stock update feeds would be most welcome.
Thanks.

I finally worked it out - I had the incorrect feed type in my post. It should have been set to _POST_INVENTORY_AVAILABILITY_DATA_.

Your XML seems to be missing </AmazonEnvelope> at the end of the feed, but that could easily be an error in pasting it here. Once I added that, I was able to validate your XML against my copy of the XSDs. Other than that, my inventory feed only differs in one way: I have an additional <FulfillmentLatency>1</FulfillmentLatency> following right after each Quanitity, which is not mandatory according to the XSDs.

Amazon MWS Update Inventory Stock Sample Code:
<?php
/**********************************************************
* Update inventory stock through amazon mws api
*
***********************************************************/
$sku1 = '10101-AM';
$quantity1 = '9';
$leadTimeToShip1 = '7';
//amazon mws credentials
$amazonSellerId = 'xxxxxx';
$amazonMWSAuthToken = 'xxxxxx';
$amazonAWSAccessKeyId = 'xxxxxx';
$amazonSecretKey = 'xxxxxx';
$amazonMarketPlaceId = 'xxxxxx';
$param = array();
$param['AWSAccessKeyId'] = $amazonAWSAccessKeyId;
$param['Action'] = 'SubmitFeed';
$param['Merchant'] = $amazonSellerId;
$param['MWSAuthToken'] = $amazonMWSAuthToken;
$param['FeedType'] = '_POST_INVENTORY_AVAILABILITY_DATA_';
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2009-01-01';
$param['MarketplaceIdList.Id.1'] = $amazonMarketPlaceId;
$param['PurgeAndReplace'] = 'false';
$secret = $amazonSecretKey;
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
$amazon_feed = '<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>'.$amazonSellerId.'</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>'.$sku1.'</SKU>
<Quantity>'.$quantity1.'</Quantity>
<FulfillmentLatency>'.$leadTimeToShip1.'</FulfillmentLatency>
</Inventory>
</Message>
</AmazonEnvelope>';
//echo $amazon_feed;exit;
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.com' . "\n";
$sign .= '/Feeds/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($amazon_feed, true));
//$httpHeader[] = 'x-amazon-user-agent: MyScriptName/1.0';
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.com/Feeds/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$errors=curl_error($ch);
curl_close($ch);
echo '<pre>';
print_r($response); //xml response
?>

Related

WebM Dash on Amazon Media Convert - No Segment Range

We're using Amazon Media Convert to create MPDs for playing WebMs. The manifest looks like this
<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" type="static" minBufferTime="PT12S" profiles="urn:mpeg:dash:profile:isoff-main:2011" mediaPresentationDuration="PT2.474S">
<Period start="PT0S" duration="PT2.474S" id="1">
<AdaptationSet mimeType="video/webm" frameRate="60000/1001" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="false">
<Representation id="1" width="1920" height="1080" bandwidth="4000000" codecs="vp9">
<BaseURL>webm.2.40.webm.VP9.webm</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" lang="eng" segmentAlignment="0">
<Representation id="2" bandwidth="96000" audioSamplingRate="48000" codecs="mp4a.40.2">
<BaseURL>webm.audio.mp4</BaseURL>
<SegmentBase indexRange="658-709">
<Initialization range="0-657"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
With the following Codec settings.
new VideoCodecSettings()
{
Codec = VideoCodec.VP9,
Vp9Settings = new Vp9Settings()
{
Bitrate = bitRate,
FramerateControl = Vp9FramerateControl.INITIALIZE_FROM_SOURCE,
RateControlMode = Vp9RateControlMode.VBR,
FramerateConversionAlgorithm =
Vp9FramerateConversionAlgorithm.DUPLICATE_DROP,
}
};
When loading in DashJS I get the following error:
WebmSegmentBaseLoader.js:298 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'split')
at WebmSegmentBaseLoader.js:298:67
at new Promise (<anonymous>)
at Object.loadInitialization (WebmSegmentBaseLoader.js:295:16)
at Object.getSegmentBaseInitSegment (SegmentBaseController.js:97:42)
at Object.updateInitData (SegmentsController.js:63:38)
at RepresentationController.js:135:46
at new Promise (<anonymous>)
at _updateRepresentation (RepresentationController.js:127:16)
at Object.updateData (RepresentationController.js:120:27)
at Object.selectMediaInfo (StreamProcesso
When it runs let initRange = representation ? representation.range.split('-') : null;
I assume it's because there is no ranges in the adaption set.
My question is how to get WebM DASH MPDs with Ranges?

Group nodes together based on condition and validate using Schematron

I am working on writing rules using Schematron to validate data below. The requirement is to verify whether a patient has at least one encounter in the past 12 months. If there are multiple encounters per patient, use the last encounter.
<root>
<entry>
<resource>
<resourceType>Encounter</resourceType>
<subject>
<id>Patient/12345</id>
</subject>
<encounterDate>2018-04-10T10:00:00</encounterDate>
</resource>
</entry>
<entry>
<resource>
<resourceType>Encounter</resourceType>
<subject>
<id>Patient/abcde</id>
</subject>
<encounterDate>2020-04-10T10:00:00</encounterDate>
</resource>
</entry>
<entry>
<resource>
<resourceType>Encounter</resourceType>
<subject>
<id>Patient/abcde</id>
</subject>
<encounterDate>2019-05-10T10:00:00</encounterDate>
</resource>
</entry>
</root>
The above data should pass the validation because the latest encounter is less than a year ago.
What I want to know is, if I write a template that groups encounters together by patient id, is there a way to pass that template to the rule context? If not, is there any other way of doing it?
I am completely new to both xslt and Schematron and here is what I have so far:
<schema xmlns="http://purl.oclc.org/dsdl/schematron" >
<pattern>
<key name="patientId" match="entry" use="/resouce/subject/id/text()"/>
<template name="dateByPatient" match="entry">
<root>
<for-each select="resource/subject/id">
<patient >
<for-each select="key('patientId',text())">
<effectiveDateTime><value-of select="./resource/encounterDate"/></effectiveDateTime>
</for-each>
</patient>
</for-each>
</root>
</template>
<let name="template">
<dateByPatient/>
</let>
<let name="latest">
<root>
<for-each select="$template/root/patient">
<patient >
<sort select="effectiveDateTime" order="descending" />
<if test="position() = 1">
<effectiveDateTime><value-of select="effectiveDateTime" /></effectiveDateTime>
</if>
</patient>
</for-each>
</root>
</let>
<rule context="$latest/root/patient/effectiveDateTime">
<let name="days" value="days-from-duration(fn:current-dateTime() - xs:dateTime(text()))" />
<assert test="days-from-duration(fn:current-dateTime() - xs:dateTime(text())) < 365">
Encounter date more than a year : <value-of select="$days" /> days
</assert>
</rule>
</pattern>
</schema>
With XSLT 3 underlying you could use
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:ns prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/>
<sch:pattern>
<sch:rule context="root">
<sch:let name="groups"
value="let $encounter-resources := entry/resource[resourceType = 'Encounter']
return map:merge(
$encounter-resources
!
map {
data(subject/id) : xs:dateTime(encounterDate)
},
map { 'duplicates' : 'combine' }
)"/>
<sch:assert
test="every $patient in map:keys($groups)
satisfies
(current-dateTime() - max($groups($patient)))
lt xs:dayTimeDuration('P365D')">At least one patient with latest encounter more than a year ago.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
Or to output more detailed information and to only process resources with type Encounter:
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:ns prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/>
<sch:pattern>
<sch:rule context="root">
<sch:let name="groups"
value="let $encounter-resources := entry/resource[resourceType = 'Encounter']
return map:merge(
$encounter-resources
!
map {
data(subject/id) : xs:dateTime(encounterDate)
},
map { 'duplicates' : 'combine' }
)"/>
<sch:let name="failing-patients"
value="map:keys($groups)[(current-dateTime() - max($groups(.))) gt xs:dayTimeDuration('P365D')]"/>
<sch:report
test="exists($failing-patients)">Patients <sch:value-of select="$failing-patients"/> with latest encounter more than a year ago.</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
I don't think you can mix Schematron and XSLT as freely as your code tries, you would need to set up an XProc pipeline to use p:xslt to group the original input and then a validation step to validate with Schematron.
As for your problems to run the second sample with node-schematron, it uses an XPath implementation that doesn't support the XPath 3.1 sort function it seems, node-schematron also fails to handle maps as intermediary results of a Schematron variable, so only stuffing all into one variable expression seems to do; two examples work:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:ns prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/>
<sch:pattern>
<sch:rule context="root">
<sch:let name="failing-patients"
value="let $encounter-resources := entry/resource[resourceType = 'Encounter'],
$groups := map:merge(
$encounter-resources
!
map {
data(subject/id) : xs:dateTime(encounterDate)
},
map { 'duplicates' : 'combine' }
)
return map:keys($groups)[(current-dateTime() - max($groups(.))) gt xs:dayTimeDuration('P365D')]"/>
<sch:report
test="exists($failing-patients)">Patients <sch:value-of select="$failing-patients"/> with latest encounter more than a year ago.</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
or
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:ns prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/>
<sch:pattern>
<sch:rule context="root">
<sch:let name="failing-patients"
value="let
$encounter-resources := entry/resource[resourceType = 'Encounter'],
$groups := fold-left(
$encounter-resources,
map{},
function($m, $e) {
map:put(
$m,
data($e/subject/id),
max((xs:dateTime($e/encounterDate), map:get($m, data($e/subject/id))))
)
})
return map:keys($groups)[(current-dateTime() - $groups(.)) gt xs:dayTimeDuration('P365D')]"/>
<sch:report test="exists($failing-patients)">Patients <sch:value-of
select="$failing-patients"/> with latest encounter more than a year
ago.</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
If you need an assertion that fails then replace the sch:report with
<sch:assert
test="empty($failing-patients)">Patients <sch:value-of select="$failing-patients"/> with latest encounter more than a year ago.</sch:assert>

django get data response from specific ip

I am working on an API integration. I am using django==1.10.5 and python34. The app involves sending request from my server to another server which is connected through a VPN.
password = "xxxxxxxxxxxxxxxxx"
spid = "xxxxxxxxxxxxxxxxx"
serviceid = "xxxxxxxxxxxxxxxxx"
sendershortcode = "xxxxxxxxxxxxxxxxx"
initiator = "xxxxxxxxxxxxxxxxx"
initiator_password = "xxxxxxxxxxxxxxxxx"
recieveridentifier = "xxxxxxxxxxxxxxxxx"
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://api-v1.gen.mm.vodafone.com/mminterface/request">
<soapenv:Header>
<tns:RequestSOAPHeader xmlns:tns="http://www.huawei.com/schema/osg/common/v2_1">
<tns:spId>"""+spid+"""</tns:spId>
<tns:serviceId>"""+serviceid+"""</tns:serviceId>
<tns:spPassword>"""+encoded_password+"""</tns:spPassword>
<tns:timeStamp>"""+reqTime+"""</tns:timeStamp>
</tns:RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
<req:RequestMsg>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<request xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/request">
<Transaction>
<CommandID>SalaryPayment</CommandID>
<LanguageCode></LanguageCode>
<OriginatorConversationID>"""+originator+"""</OriginatorConversationID>
<ConversationID></ConversationID>
<Remark></Remark>
<Parameters>
<Parameter>
<Key>Amount</Key>
<Value>200</Value>
</Parameter>
</Parameters>
<ReferenceData>
<ReferenceItem>
<Key>QueueTimeoutURL</Key>
<Value>http://138.197.41.74:80/user/test/</Value>
</ReferenceItem>
</ReferenceData>
<Timestamp>"""+reqTime+"""</Timestamp>
</Transaction>
<Identity>
<Caller>
<CallerType>2</CallerType>
<ThirdPartyID>broker_4</ThirdPartyID>
<Password>k+JtvqNV3eg=</Password>
<CheckSum>CheckSum0</CheckSum>
<ResultURL>http://138.197.41.74:80/results/B2C/</ResultURL>
</Caller>
<Initiator>
<IdentifierType>11</IdentifierType>
<Identifier>"""+initiator+"""</Identifier>
<SecurityCredential>YwBlXbjEFjh/UQ0cZhrk+4X9TxAIc3z8zf4rXZRZRLW32cm+c/lJYQ3ZFVThna+41x8EukAHZhuR44QiF5J1GF/9QaYwK1i1rIX2i/Fa9bRJ4fn/REYd/vE1/pUPn4GnfLib151RYQyO7KsLipLFk8Hr9SYq62MSrOxgyAd1bJXQ4SdEJwk0LtCZSTWBaZySbPJt/P0FBfG71kLkrP0P0pn1cuuuJoA3KJ5+RuX5WpsXR0HFFyyJFEwAlQ9oSmKW5fzCwEKMaKTKgScfyDXmhuiFZvrSmdV3H0o4Hhl17IQR8M1fwIk9JfxrSUqVRBrEqVKJrOOlSF/T7xLJTo0fpQ==</SecurityCredential>
<ShortCode>777133</ShortCode>
</Initiator>
<PrimaryParty>
<IdentifierType>4</IdentifierType>
<Identifier>777133</Identifier>
<ShortCode>777133</ShortCode>
</PrimaryParty>
<ReceiverParty>
<IdentifierType>1</IdentifierType>
<Identifier>"""+recieveridentifier+"""</Identifier>
<ShortCode>ShortCode1</ShortCode>
</ReceiverParty>
<AccessDevice>
<IdentifierType>1</IdentifierType>
<Identifier>Identifier3</Identifier>
</AccessDevice>
</Identity>
<KeyOwner>1</KeyOwner>
</request>]]></req:RequestMsg>
</soapenv:Body>
</soapenv:Envelope>"""
headers = {'content-type': 'Content-Type: text/xml; charset=utf-8'}
url = "http://xxx.xxx.xxxx.xxx:xxxx/mminterface/request"
response = requests.post(url=url, headers = headers, data = body)
#print (response.content)
respO = xmltodict.parse(response.content)
myresponse = json.dumps(respO)
This code works fine i am able to get a respose from the other server.
My question is the other server is sending some other data which am getting when i tcpdup response i.e. tcpdump -A -s 0 'src xxx.xxx.xxx.xxx and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
From doing this am getting this content.
<?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<res:ResultMsg xmlns:res="http://api-v1.gen.mm.vodafone.com/mminterface/result">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Result xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/result">
<ResultType>0</ResultType>
<ResultCode>0</ResultCode>
<ResultDesc>The service request has been accepted successfully.</ResultDesc>
<OriginatorConversationID>Z8MPEFVZ</OriginatorConversationID>
<ConversationID>AG_20170508_00006c8d2d96c6efbeab</ConversationID>
<TransactionID>LE80192FMG</TransactionID>
<ResultParameters>
<ResultParameter>
<Key>TransactionReceipt</Key>
<Value>LE80192FMG</Value>
</ResultParameter>
<ResultParameter>
<Key>TransactionAmount</Key>
<Value>200</Value></ResultParameter>
<ResultParameter>
<Key>B2CWorkingAccountAvailableFunds</Key>
<Value>0.00</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CUtilityAccountAvailableFunds</Key>
<Value>5508.00</Value>
</ResultParameter>
<ResultParameter>
<Key>TransactionCompletedDateTime</Key>
<Value>08.05.2017 09:37:07</Value>
</ResultParameter>
<ResultParameter>
<Key>ReceiverPartyPublicName</Key>
<Value>254703381233</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CChargesPaidAccountAvailableFu 06:38:49.685570 IP 196-201-214-127.safaricom.co.ke.60575 > mambowallet.http: Flags [P.], seq 1380:1741, ack 1, win 4380, length 361 ..gP...5 ..nds</Key>
<Value>-275.00</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CRecipientIsRegisteredCustomer</Key>
<Value>N</Value></ResultParameter>
</ResultParameters>
<ReferenceData><ReferenceItem>
<Key>QueueTimeoutURL</Key>
<Value>http://138.197.41.74:80/user/test/</Value>
</ReferenceItem>
</ReferenceData>
</Result>]]>
</res:ResultMsg>
</soapenv:Body> </soapenv:Envelope>
Can someone help how i can get this content on the django view?
tcpdump image
you can do a tcpdump inside your python code using subprocess:
from subprocess import check_output
out = check_output(['tcpdump','args'])
you get the response in out and then you can work with it. for example:
out = check_output(['tcpdump', 'ether[0] & 1 = 0 and ip[16] >= 224'])
and you need to be root also

How to add WS security element to SOAP request on powershell?

I got pretty standard powershell script that sends request to web service:
$ws = New-WebServiceProxy -uri "http://server:7801/path/service?wsdl"
$ws | get-member -type method
$ws.service.OverloadDefinitions
$header = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1801_service_wsdl.header
$data = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1801_esb_service_wsdl.data
# $header
# $data
$header.channel = ...
$data.Password = ...
$bar = $ws.service($header, $data)
It works fine, and now I want to add oasis ws-security component to the request's SOAP header:
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>Yolo McSwaggen</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
How do I do it?

PowerShell Script to replace lines between strings using RegEx

i wanted to replace what ever lines come between
<? and <Arguments>
and also
</Arguments> and </Task>
via powershell and regex
here's the entire string
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Author>administrator</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<Enabled>true</Enabled>
<StartBoundary>2013-03-13T00:34:00</StartBoundary>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Settings>
<Enabled>true</Enabled>
<ExecutionTimeLimit>PT259200S</ExecutionTimeLimit>
<Hidden>false</Hidden>
<WakeToRun>false</WakeToRun>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<Priority>5</Priority>
<IdleSettings>
<Duration>PT600S</Duration>
<WaitTimeout>PT3600S</WaitTimeout>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Principals>
<Principal id="Author">
<RunLevel>HighestAvailable</RunLevel>
<UserId>SMETEST\Administrator</UserId>
<LogonType>InteractiveTokenOrPassword</LogonType>
</Principal>
</Principals>
<Actions Context="Author">
<Exec>
<Command>C:\Program Files\NetApp\SnapManager for Exchange\SMEJobLauncher.exe</Command>
<Arguments>new-backup -Server 'SME' -ManagementGroup 'Standard' -RetainBackups 8 -RetainUtmBackups 20 -Sto
rageGroup 'testingDB1' -UseMountPoint -MountPointDir 'C:\Program Files\MgrMountPoi
nt' -RemoteAdditionalCopyBackup $False</Arguments>
<WorkingDirectory>C:\Program Files\NetApp\SnapManager for Exchange\</WorkingDirectory>
</Exec>
</Actions>
</Task>
i just want the output to look like
new-backup -Server 'SME' -ManagementGroup 'Standard' -RetainBackups 8 -RetainUtmBackups 20 -StorageGroup 'testingDB1' -UseMountPoint -MountPointDir 'C:\Program Files\MgrMountPoint' -RemoteAdditionalCopyBackup $False
Instead of wasting time on regex with XML - use Select-Xml and XPath:
Select-Xml -Path .\Test.xml -Namespace #{
t = "http://schemas.microsoft.com/windows/2004/02/mit/task"
} -XPath //t:Arguments | foreach { $_.node.InnerText -replace '\n' }
I've remove newlines, assuming that's what you want.