Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to call a wcf web service where the SOAPAction name is different to the Request name (Envelope->Body->RequestName) within the envelope body. How can a specify a different SOAPAction and Request element name?

Replies are listed 'Best First'.
Re: SOAP lite with WCF
by Anonymous Monk on Jul 05, 2013 at 03:18 UTC

    Can you given an example of what that looks like (HTTP request/ XML request)?

      <HttpRequest> <Method>POST</Method> <QueryString></QueryString> <WebHeaders> <Content-Length>1245</Content-Length> <Content-Type>text/xml; charset=utf-8</Content-Type> <Accept-Encoding>gzip, deflate</Accept-Encoding> <Expect>100-continue</Expect> <Host>[hostname]</Host> <SOAPAction>"urn:::profilemanager:requestmanager:100818. +ProfileScopeServiceContract.ProcessMessage"</SOAPAction> </WebHeaders> </HttpRequest> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelop +e/"> <s:Header> <ActivityId CorrelationId="0d113c44-878d-40c4-bc3d-37a1a +c9a693e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Dia +gnostics">00000000-0000-0000-0000-000000000000</ActivityId> <To s:mustUnderstand="1" xmlns="http://schemas.microsoft +.com/ws/2005/05/addressing/none">http://[hostname]/ProfileManager/100 +818/ProfileManager.svc</To> <Action s:mustUnderstand="1" xmlns="http://schemas.micro +soft.com/ws/2005/05/addressing/none">urn:::profilemanager:requestmana +ger:100818.ProfileScopeServiceContract.ProcessMessage</Action> </s:Header> <s:Body> <Request xmlns="urn:::profilemanager:profilemanagerreque +stmanager:100818" xmlns:a="urn:::profilemanager:requestmanager" xmlns +:i="http://www.w3.org/2001/XMLSchema-instance"> <a:Payload i:type="b:Organisation" xmlns:b="urn:::prof +ilemanager:contract:110308"> <b:OrganisationUnitId></b:OrganisationUnitId> <b:OrganisationDescription i:nil="true"></b:Organisa +tionDescription> <b:IsCustomer i:nil="true"></b:IsCustomer> <b:IsDealer i:nil="true"></b:IsDealer> <b:IsSupplier i:nil="true"></b:IsSupplier> <b:Domains i:nil="true"></b:Domains> <b:AccountFormat i:nil="true"></b:AccountFormat> <b:ShouldUserNameMatchEmailFormat i:nil="true"></b:S +houldUserNameMatchEmailFormat> <b:ShouldUserNameHaveDomain i:nil="true"></b:ShouldU +serNameHaveDomain> <b:ShouldEmailHaveDomain i:nil="true"></b:ShouldEmai +lHaveDomain> </a:Payload> <a:ProcessingInstruction xmlns:b="urn:::profilemanager +:contract:common:100818"> <b:Action>GetOrganisationById</b:Action> <b:Strategy> <b:Name i:nil="true"></b:Name> <b:Paging i:nil="true"></b:Paging> <b:SearchCriteria i:nil="true"></b:SearchCriteria> </b:Strategy> <b:Meta i:nil="true"></b:Meta> </a:ProcessingInstruction> </Request> </s:Body> </s:Envelope> </MessageLogTraceRecord> </DataItem> </TraceData> </ApplicationData> </E2ETraceEvent>
      I've removed sensitive content from namespaces but you can see the soap action and envelope/body/request element are different. Generally they are the same
      I believe the same question was asked in the following link however as I am new to Perl I dont understand the answer http://code.activestate.com/lists/perl-xml/8922/
      My script is like this
      #!/usr/bin/perl package main; use SOAP::Lite +trace; use LWP::UserAgent; use HTTP::Request::Common; # Variables my $url = 'http://[hostname]/ProfileManager/100818/ProfileManager.svc? +wsdl'; my $url_debug = 'http://localhost:11040/Service1.svc?wsdl'; my $uri = 'urn:::profilemanager:profilemanagerrequestmanager:100818'; my $soap = SOAP::Lite -> ns( 'http://www.w3.org/2001/XMLSchema-instance', 'xsi' ) -> ns( 'urn:::profilemanager:requestmanager', 'a' ) -> ns( 'urn:::profilemanager:contract:110308', 'b' ) -> uri($uri) -> on_action( sub { join '.', 'urn:::profilemanager:requestmanager:100 +818.ProfileScopeServiceContract', $_[1] } ) -> proxy($url); my $method = SOAP::Data->name('ProcessMessage') ->attr({xmlns => 'urn:::profilemanager:profilemanagerrequestmanager:10 +0818'}); my @params = ( SOAP::Data->type("b:Organisation")->name("a:Payload")-> +value( \SOAP::Data->value( SOAP::Data->name("b:OrganisationUnitId")->value(""), SOAP::Data->name("b:OrganisationDescription")->attr( { 'xsi:nil' => "t +rue" } ) ) ), SOAP::Data->name("a:ProcessingInstruction")->value( \SOAP::Data->value( SOAP::Data->name("b:Action")->value("GetOrganisationById"), SOAP::Data->name("b:Strategy")->value( \SOAP::Data->value( SOAP::Data->name("b:Name")->attr( { 'xsi:nil' => "true" } ), SOAP::Data->name("b:Paging")->attr( { 'xsi:nil' => "true" } ), SOAP::Data->name("b:SearchCriteria")->attr( { 'xsi:nil' => "true" + } ) ) ), SOAP::Data->name("b:Meta")->attr( { 'xsi:nil' => "true" } ) ) ) ); print $soap->call($method => @params)->result;