I have already created a Query Activity in Salesforce marketing cloud using the SOAP API and it was success. My next step to update the SQL Query in the Query Activity using SOAP API. Unfortunately in the documentation, they haven't provided the SOAP envelop format.
Documentation : https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/updating_a_query_activity.htm
So far I tried something like below and it was not success.
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsse:Security soap:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>myUsername</wsse:Username>
<wsse:Password>MyPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<UpdateRequest
xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Objects xsi:type="QueryDefinition">
<PartnerKey xsi:nil="true"></PartnerKey>
<ObjectID xsi:nil="true"></ObjectID>
<CustomerKey>1542788641356_QueryActivity</CustomerKey>
<Client>
<ID>7665587</ID>
</Client>
<Definitions>
<Definition xsi:type="QueryDefinition">
<ObjectID>354afdc3-iida-4c17-fdd7-2d1855rttbea7</ObjectID>
</Definition>
</Definitions>
<QueryText>SELECT firstname,lastname,PersonContactId FROM Distributed_Marketing_Conso_335</QueryText>
<TargetType>DE</TargetType>
<DataExtensionTarget>
<PartnerKey xsi:nil="true"></PartnerKey>
<Name>1542788641356_DataExtension</Name>
</DataExtensionTarget>
<TargetUpdateType>Overwrite</TargetUpdateType>
</Objects>
</UpdateRequest>
</soap:Body>
Appreciate your help to find a Working SOAP Envelop format to update the Query Activity.