How to fix the WSDL file not well-formed (invalid token) issue - perl

I have created WSDL file connect the file with PERL soap method. After the exection i get the below error message
"not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm line 187." .
Please let me know have to fix the issue. Review below source code.
soap-client.pl
#!/usr/bin/perl -w
#use SOAP::Lite +trace => ‘debug’;
use SOAP::Lite;
my $client = SOAP::Lite
->service('http://localhost/soap/perl/marketplace.wsdl');
my $result = $client->login( 'test_user', 'test_password' );
#~ my $result = $client->sayHello('');
print $result;
soap-server.pl
#!/usr/bin/perl
function login( $login, $password )
{
return $login;
}
function doFilter( $params )
{
return "some string";
}
marketplace.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Marketplace"
targetNamespace="urn:Marketplace"
xmlns:tns="urn:Marketplace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="LoginRequest">
<part name="login" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="LoginResponse">
<part name="result" type="xsd:string"/>
</message>
<portType name="LoginPort">
<operation name="login">
<input message="tns:LoginRequest"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="LoginBinding" type="tns:LoginPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction="urn:LoginAction"/>
<input>
<soap:body use="encoded" namespace="urn:Marketplace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Marketplace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="WSDLService">
<port name="LoginPort" binding="tns:LoginBinding">
<soap:address location="http://localhost/soap/perl/soap-server.pl"/>
</port>
</service>
</definitions>
finally run the soap-client.pl file return below error message.
"not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm line 187." .

Uncomment #use SOAP::Lite +trace => ‘debug’; line and see the resulting error.

Related

Application service not found

I have created SOAP service in NetBeans 13 that starts on GlassFish server with minor warnings:
Tue Jan 31 16:54:05 EET 2023 : Security manager installed using the Basic server security policy.
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.apache.derby.drda.NetworkServerControl (file:/C:/java_test/AppServer/Glassfish/javadb/lib/derbynet.jar)
WARNING: Please consider reporting this to the maintainers of org.apache.derby.drda.NetworkServerControl
WARNING: System::setSecurityManager will be removed in a future release
Tue Jan 31 16:54:05 EET 2023 : Apache Derby Network Server - 10.15.2.0 - (1873585) started and ready to accept connections on port 1527
Service code:
package javaeetutorial.helloservice;
import javax.jws.WebService;
import javax.jws.WebMethod;
#WebService
public class Hello {
private final String message = "Hello, ";
public Hello() {
}
#WebMethod
public String sayHello(String name) {
return message + name + ".";
}
#WebMethod
public String sayHello2(String name) {
return message + name + ".";
}
}
I found WSDL file of this project in location \helloservice-war\target\generated-sources\wsdl\HelloService.wsdl
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI (https://github.com/eclipse-ee4j/metro-jax-ws). RI's version is JAX-WS RI 2.3.3 git-revision#b4c5bb6. -->
<definitions targetNamespace="http://helloservice.javaeetutorial/" name="HelloService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:tns="http://helloservice.javaeetutorial/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
<types>
<xsd:schema>
<xsd:import namespace="http://helloservice.javaeetutorial/" schemaLocation="HelloService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="sayHello2">
<part name="parameters" element="tns:sayHello2"/>
</message>
<message name="sayHello2Response">
<part name="parameters" element="tns:sayHello2Response"/>
</message>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="Hello">
<operation name="sayHello2">
<input wsam:Action="http://helloservice.javaeetutorial/Hello/sayHello2Request" message="tns:sayHello2"/>
<output wsam:Action="http://helloservice.javaeetutorial/Hello/sayHello2Response" message="tns:sayHello2Response"/>
</operation>
<operation name="sayHello">
<input wsam:Action="http://helloservice.javaeetutorial/Hello/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="http://helloservice.javaeetutorial/Hello/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="HelloPortBinding" type="tns:Hello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello2">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloService">
<port name="HelloPort" binding="tns:HelloPortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
When I run project from IDE it opens browser on adrees http://localhost:8080/helloservice-war/HelloService?Tester . Browser window shows error 404-Not found
I feed WSDL to SOAPUI client and have changed service path REPLACE_WITH_ACTUAL_URL to http://localhost:8080/helloservice-war/HelloService . I called function sayHello, but got 404 error.
Where is my service located and how to call it's functions?
GlassFish console:

PERL WCF Web Service Call Fails

I am making web service calls using PERL to one of our vendor provided web services. The web services use SOAP 1.2 and WSHttpBinding.
I am able to make calls successfully to most of the calls in the web service, except for the RetrieveReport call. The RetrieveReport call is supposed to stream a file. However I am getting the response below.
An example to call the RetrieveReport was provided using C# code mentioning to use the following binding. However I have no clue how to do this in PERL. If anyone can provide any assistance, I thank you in advance.
C# App Config Binding
<binding name="WSHttpBinding_IBIStreamService" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
PERL Code
my $reportKey = 'report_key';
my $reportUri = 'report_uri';
my $xml = new XML::Simple;
my $userAgent = LWP::UserAgent->new(agent => 'https://service.com/services/BIDataService');
my $message = <<'.';
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://service.com/dataservices/bistream/2/IBIStreamService/RetrieveReport</a:Action>
<h:ReportKey xmlns:h="http://service.com/dataservices/bistream/2" xmlns="http://service.com/dataservices/bistream/2">[ReportKey]</h:ReportKey>
<a:To s:mustUnderstand="1">[ReportRetrievalUri]</a:To>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RetrieveReportRequest xmlns="http://service.com/dataservices/bistream/2" />
</s:Body>
</s:Envelope>
.
# Replace the dynamic values
$message =~ s/\[ReportKey\]/$reportKey/g;
$message =~ s/\[ReportRetrievalUri\]/$reportUri/g;
my $request = HTTP::Request->new(POST => $uri);
$request->header(SOAPAction => '"http://service.com/dataservices/bistream/2/IBIStreamService/RetrieveReport"');
$request->content($message);
$request->content_type("application/soap+xml; charset=utf-8");
print "-- CONTENT --\n\n";
print $request->content . "\n\n";
my $response = $userAgent->request($request);
if ($response->is_success) {
print "--SUCCESS--\n" . $response->decoded_content . "\n";
} else {
print "--FAILURE--\n" . $response->status_line, "\n";
print $response->error_as_HTML;
}
Response From Vendor
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/fault</a:Action>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value>a:ActionNotSupported</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">The message with Action \'http://service.com/dataservices/bistream/2/IBIStreamService/RetrieveReport\' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
WSDL Source
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="BIStreamService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:i0="http://service.com/dataservices/bistream/2" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
<wsp:Policy wsu:Id="WSHttpBinding_IBIStreamService_policy">
<wsp:ExactlyOne>
<wsp:All>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:import namespace="http://service.com/dataservices/bistream/2" location="https://service.com/services/BIStreamingService?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="WSHttpBinding_IBIStreamService" type="i0:IBIStreamService">
<wsp:PolicyReference URI="#WSHttpBinding_IBIStreamService_policy"/>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveReport">
<soap12:operation soapAction="http://service.com/dataservices/bistream/2/IBIStreamService/RetrieveReport" style="document"/>
<wsdl:input name="RetrieveReportRequest">
<soap12:header message="i0:RetrieveReportRequest_Headers" part="ReportKey" use="literal"/>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="StreamReportResponse">
<soap12:header message="i0:StreamReportResponse_Headers" part="Status" use="literal"/>
<soap12:header message="i0:StreamReportResponse_Headers" part="StatusMessage" use="literal"/>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="BasicHttpBinding_IBIStreamService" type="i0:IBIStreamService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveReport">
<soap:operation soapAction="http://service.com/dataservices/bistream/2/IBIStreamService/RetrieveReport" style="document"/>
<wsdl:input name="RetrieveReportRequest">
<soap:header message="i0:RetrieveReportRequest_Headers" part="ReportKey" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="StreamReportResponse">
<soap:header message="i0:StreamReportResponse_Headers" part="Status" use="literal"/>
<soap:header message="i0:StreamReportResponse_Headers" part="StatusMessage" use="literal"/>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BIStreamService">
<wsdl:port name="WSHttpBinding_IBIStreamService" binding="tns:WSHttpBinding_IBIStreamService">
<soap12:address location="https://service.com/services/BIStreamingService"/>
<wsa10:EndpointReference>
<wsa10:Address>https://service.com/services/BIStreamingService</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
<wsdl:port name="BasicHttpBinding_IBIStreamService" binding="tns:BasicHttpBinding_IBIStreamService">
<soap:address location="https://service.com/services/BIStreamingService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I found out the issue.
There are two URLs for the report web service. One to execute the report and a different one to retrieve the report. I modified the LWP::UserAgent->new(agent => '') and the HTTP::Request->new(POST => '') to both point to https://service.com/services/BIStreamingService when retrieving the report and now it works.
Thank you!

java.lang.Exception: No such operation: login j

I'm trying to invoke sfdc login webservice from mule. I generated classes using apache cxxf wsdl2java on partner wsdl. I tried all possible ways of sending the input,but still continue to get the "java.lang.Exception: No such operation: login" error
Following is my flow:
<mule....>
<cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
<flow name="mainFlow1" doc:name="mainFlow1">
<http:inbound-endpoint exchange-pattern="request-response" path="sfdclogin" host="localhost" port="8081" doc:name="HTTP"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[import com.sforce.soap.partner.*;
ObjectFactory of= new ObjectFactory();
com.sforce.soap.partner.Login loginReq=new com.sforce.soap.partner.Login();
loginReq.setUsername("username");
loginReq.setPassword("password");
return loginReq;]]></scripting:script>
</scripting:component>
<cxf:jaxws-client operation="login" serviceClass="com.sforce.soap.partner.SforceService" doc:name="SOAP"/>
<https:outbound-endpoint address="https://test.salesforce.com/services/Soap/u/30.0" exchange-pattern="request-response" method="POST" doc:name="HTTPS"/>
</flow>
</mule>
Exception stack trace. As can be seen below, correct object of Login type is being passed to SOAP component.
Object after transform: com.sforce.soap.partner.Login#5d9683ed
The transformed object is of expected type. Type is: Login
********************************************************************************
Message : No such operation: login. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Login
Type : org.mule.api.transport.DispatchException
Code : MULE_ERROR--2
Payload : com.sforce.soap.partner.Login#5d9683ed
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html
********************************************************************************
Exception stack is:
1. No such operation: login (java.lang.Exception)
org.mule.module.cxf.CxfOutboundMessageProcessor:282 (null)
2. No such operation: login. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Login (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
********************************************************************************
Root Exception stack trace:
java.lang.Exception: No such operation: login
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:282)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:363)
WSDL:
<!-- Login Message Types -->
<element name="login">
<complexType>
<sequence>
<element name="username" type="xsd:string"/>
<element name="password" type="xsd:string"/>
</sequence>
</complexType>
</element>
<message name="loginRequest">
<part element="tns:login" name="parameters"/>
</message>
<!-- Soap PortType -->
<portType name="Soap">
<operation name="login">
<documentation>Login to the Salesforce.com SOAP Api</documentation>
<input message="tns:loginRequest"/>
<output message="tns:loginResponse"/>
<fault message="tns:LoginFault" name="LoginFault"/>
<fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
<fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
</operation>
</portType>
<!-- Soap Binding -->
<binding name="SoapBinding" type="tns:Soap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
<soap:header use="literal" message="tns:Header" part="CallOptions"/>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="LoginFault">
<soap:fault name="LoginFault" use="literal"/>
</fault>
<fault name="UnexpectedErrorFault">
<soap:fault name="UnexpectedErrorFault" use="literal"/>
</fault>
<fault name="InvalidIdFault">
<soap:fault name="InvalidIdFault" use="literal"/>
</fault>
</operation>
</binding>
<!-- Soap Service Endpoint -->
<service name="SforceService">
<documentation>Sforce SOAP API</documentation>
<port binding="tns:SoapBinding" name="Soap">
<soap:address location="https://test.salesforce.com/services/Soap/u/30.0"/>
</port>
</service>

Matlab compatible .wsdl file

I trying to make a web service accessible to Matlab. I can call it from PHP but Matlab doesn't seem to be able to parse the definition.
??? Attempt to reference field of non-structure array.
Error in ==> createClassFromWsdl>parseWsdl at 72
se = defTypes.getExtensibilityElements().get(0);
Error in ==> createClassFromWsdl at 32
[R, schema] = parseWsdl(wsdlUrl);
WSDL File:
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='server3'
targetNamespace='http://server.edu/php/soap_test/server3.wsdl'
xmlns:tns='http://server.edu/php/soap_test/server3.wsdl'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<xsd:complexType name="ActivityData">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="HomeId" type="string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="TStamp" type="string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="Description" type="string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfActivityData">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="keyval" type="tns:ActivityData"/>
</xsd:sequence>
</xsd:complexType>
<message name='getRangeRequest'>
<part name='inHomeId' type='xsd:int'/>
<part name='inStartDate' type='xsd:string'/>
<part name='inEndDate' type='xsd:string'/>
</message>
<message name='getRangeResponse'>
<part name='out1' type='ArrayOfActivityData'/>
</message>
<portType name='getRangePortType'>
<operation name='getRange'>
<input message='tns:getRangeRequest'/>
<output message='tns:getRangeResponse'/>
</operation>
</portType>
<binding name='getRangeBinding' type='tns:getRangePortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getRange'>
<soap:operation soapAction='urn:xmethods-get-range#getRange'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-get-range' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-get-range' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='getRangeService'>
<port name='getRangePort' binding='getRangeBinding'>
<soap:address location='http://server.edu/php/soap_test/soap_server3.php'/>
</port>
</service>
</definitions>
Reading the Matlab docs states:
The createClassFromWsdl function works with WSDL documents that comply with the WS-I 1.0 standard and use one of these forms: RPC-encoded, RPC-literal, Document-literal, or Document-literal-wrapped.
My Matlab install works with some sample WSDL files. So now Im trying to figure out what's wrong with mine. Suggestions?
FWIW: There are four issues:
1) the 'xsd:complexType' entries need to be in a 'types' section.
2) the 'service/port#binding' attribute needs to be 'tns:getRangeBinding'.
3) 'binding/operation/soap:operation#soapAction' should be 'urn:xmethods-get-range:getRange'
4) 'binding/operation/input/soap:body#namespace' should match #3.

Making SOAP call using Perl's SOAP::Lite and a WSDL file

I want to make a SOAP call to a local web service. The web service is defined via a WSDL file (see below). I want to use Perl and SOAP::Lite. I tried this:
use strict ;
use warnings ;
use SOAP::Lite ;
my $endpoint = qq{http://example.com:2222/orawsv/PS_API/ACCOUNT_WS} ;
my $tns = 'http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS' ;
my $method_urn = $tns ;
my $soapaction = $tns ;
my $method = 'GET_BY_ACCOUNT_NUMBER' ;
my $sObj = SOAP::Lite->new(uri => $soapaction, proxy => $endpoint) ;
my $response = $sObj->call(SOAP::Data->name($method)->attr({ 'xmlns' => $method_urn})
=> SOAP::Data->name('ACCOUNT_NUMBER-VARCHAR2-IN' => '274724')) ;
print $response->faultstring() . "\n";
However, this results in an XML parsing failed error message. What would be the correct SOAP::Lite code to make this method call?
The HTTP request generated by the above is
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 553
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS#GET_BY_ACCOUNT_NUMBER"
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GET_BY_ACCOUNT_NUMBER xmlns="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS">
<ACCOUNT_NUMBER-VARCHAR2-IN xsi:type="xsd:int">274724</ACCOUNT_NUMBER-VARCHAR2-IN>
</GET_BY_ACCOUNT_NUMBER>
</soap:Body>
</soap:Envelope>
Here is the WSDL file defining the web service:
<definitions name="ACCOUNT_WS"
targetNamespace="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/PS_API/ACCOUNT_WS" elementFormDefault="qualified">
<xsd:element name="CACCOUNT_A-GET_BY_ACCOUNT_NUMBERInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ACCOUNT_NUMBER-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GET_BY_ACCOUNT_NUMBEROutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="GET_BY_ACCOUNT_NUMBERInputMessage">
<part name="parameters" element="tns:CACCOUNT_A-GET_BY_ACCOUNT_NUMBERInput"/>
</message>
<message name="GET_BY_ACCOUNT_NUMBEROutputMessage">
<part name="parameters" element="tns:GET_BY_ACCOUNT_NUMBEROutput"/>
</message>
<portType name="ACCOUNT_WSPortType">
<operation name="GET_BY_ACCOUNT_NUMBER">
<input message="tns:GET_BY_ACCOUNT_NUMBERInputMessage"/>
<output message="tns:GET_BY_ACCOUNT_NUMBEROutputMessage"/>
</operation>
</portType>
<binding name="ACCOUNT_WSBinding" type="tns:ACCOUNT_WSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GET_BY_ACCOUNT_NUMBER">
<soap:operation soapAction="GET_BY_ACCOUNT_NUMBER"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="ACCOUNT_WSService">
<documentation>Oracle Web Service</documentation>
<port name="ACCOUNT_WSPort" binding="tns:ACCOUNT_WSBinding">
<soap:address location="http://example.com:2222/orawsv/PS_API/ACCOUNT_WS"/>
</port>
</service>
</definitions>
Since you have the WSDL, you shouldn't have to construct SOAP::Data objects at all. Simply load the WSDL into your client object and call the method directly:
my $client = SOAP::WSDL->new(wsdl => $url_of_wsdl);
my $result = $client->$method(#arguments);
Yes, it's that easy!
Looks like this is about a year old, so this might not be relevant any longer. Anyway, based on the soap::lite documentation on CPAN it looks like you want to do this:
my $response = $sObj->call(SOAP::Data->name($method)->attr({ 'xmlns' => $method_urn}),
SOAP::Data->name('parameters')->value(SOAP::Data->value([
SOAP::Data->name('ACCOUNT_NUMBER-VARCHAR2-IN' => '274724'),
]))
);
die $response->fault->{ faultstring } if ($response->fault);
print $response->result, "\n";