I am using perl soap::lite to build a web services client.
The implementation works fine for simple methods, which will e.g. require a single scalar argument.
EG, the following works fine.
#!/usr/bin/perl
use warnings;
use SOAP::Lite +trace=>debug;
use strict;
use Data::Dumper;
$SOAP::Constants::PREFIX_ENV = 'SOAP-ENV';
my $base="https://XXXX:60001/GDBIncidentWebService/Config?wsdl&style=rpc";
my $user="XXXX";
my $pwd="XXXX";
my $lite = SOAP::Lite -> readable(1)
-> service($base) ;
my #res=$lite->readIncident("123456");
print Dumper(\#res);
exit;
sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pwd ; }
I need to call one method which requires a more complex set of arguments(a few scalars plus one array of key-value pairs).
I figure I should use the SOAP::Data module to serialize my data correctly but fail to get it to work.
Even the "simple" methods (like the one above) do not seem to work.
EG (just showing lines changed from above script) :
my $arg= SOAP::Data->new()->type('xs:string')-> value("20054106");
my #res=$lite->readIncident($arg);
Yields:
String value expected instead of SOAP::Data reference
Any idea on how to fix this ? Thanks a lot !
For reference here is the wsdl for the method called in my script
<wsdl:operation name="readIncident">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi" parts="ticketID "/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi"/>
</wsdl:output>
</wsdl:operation>
The full WSDL looks like follows - spread into 3 files. Main WSDL file:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="GDBIncidentWebServiceWsd" targetNamespace="urn:GDBIncidentWebServiceWsd" xmlns:bns0="urn:GDBIncidentWebServiceWsd/Config/rpc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:import location="./bindings/Config_rpc.wsdl" namespace="urn:GDBIncidentWebServiceWsd/Config/rpc"/>
<wsdl:service name="GDBIncidentWebService">
<wsdl:port name="ConfigPort_Rpc" binding="bns0:ConfigBinding">
<soap:address location="http://xxxx/GDBIncidentWebService/Config?style=rpc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Bindings file (extract)
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ns0="urn:com.dbag.gde.gdb.types" targetNamespace="urn:GDBIncidentWebServiceWsd/GDBIncidentWebServiceVi/rpc" xmlns:tns="urn:GDBIncidentWebServiceWsd/GDBIncidentWebServiceVi/rpc" xmlns:ns2="urn:java/lang">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:com.dbag.gde.gdb.types" xmlns:tns="urn:com.dbag.gde.gdb.types" elementFormDefault="qualified">
<xs:complexType name="KeyValuePair">
<xs:sequence>
<xs:element name="key" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="value" type="xs:string" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ArrayOfKeyValuePair">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="KeyValuePair" type="tns:KeyValuePair" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java/lang" xmlns:tns="urn:java/lang" elementFormDefault="qualified">
<xs:complexType name="ArrayOfString">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="String" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="createInsourcingIncidentIn">
<wsdl:part name="externalKey" type="ns1:string"/>
<wsdl:part name="title" type="ns1:string"/>
<wsdl:part name="description" type="ns1:string"/>
<wsdl:part name="impact" type="ns1:string"/>
<wsdl:part name="urgency" type="ns1:string"/>
<wsdl:part name="contact" type="ns1:string"/>
<wsdl:part name="creatorGroup" type="ns1:string"/>
<wsdl:part name="category1" type="ns1:string"/>
<wsdl:part name="category2" type="ns1:string"/>
<wsdl:part name="category3" type="ns1:string"/>
<wsdl:part name="extReference" type="ns0:ArrayOfKeyValuePair"/>
<wsdl:part name="attachments" type="ns0:ArrayOfAttachment"/>
<wsdl:part name="additionalFields" type="ns0:ArrayOfKeyValuePair"/>
<wsdl:part name="assignmentGroup" type="ns1:string"/>
<wsdl:part name="assignmentSubGroup" type="ns1:string"/>
<wsdl:part name="productId" type="ns1:string"/>
<wsdl:part name="productName" type="ns1:string"/>
<wsdl:part name="service" type="ns1:string"/>
<wsdl:part name="customer" type="ns1:string"/>
</wsdl:message>
<wsdl:portType name="GDBIncidentWebServiceVi_Rpc">
<wsdl:operation name="createInsourcingIncident">
<wsdl:input message="tns:createInsourcingIncidentIn"/>
<wsdl:output message="tns:createInsourcingIncidentOut"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
Operation definition
<wsdl:operation name="createInsourcingIncident">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi" parts="externalKey title description impact urgency contact creatorGroup category1 category2 category3 extReference attachments additionalFields assignmentGroup assignmentSubGroup productId productName service customer "/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi"/>
</wsdl:output>
</wsdl:operation>
Update and resolution.
It looks like using the proxy/uri method to create the SOAP::Lite object (instead of simply referencing the WSDL "service") strings is mandatory if you want to pass complex data
Therefore the code now looks as follows for the simple request :
my $base="https://XXXXX/GDBIncidentWebService/Config?wsdl&style=rpc";
my $uri="urn:GDBIncidentWebServiceVi"
my $ticketID='20054106';
my $lite = SOAP::Lite -> proxy($base)
-> uri($uri);
my $res = $lite -> readIncident(SOAP::Data->('ticketID' => $ticketID))
-> result;
print Dumper($res);
Related
We are changing our soap webservices from jetty to jaxws. The goal is to keep the same input message. I have used the original WSDL to create the service with netbeans. The WSDL is the following:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
<xs:complexType name="DcxExpeditie">
<xs:sequence>
<xs:element name="Expeditie" type="tns:Expeditie"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Expeditie">
<xs:sequence>
<xs:element name="tag1" type="xs:string"/>
<xs:element name="tag2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="DcxExpeditieRequest">
<wsdl:part name="DcxExpeditie" type="tns:DcxExpeditie"/>
</wsdl:message>
<wsdl:message name="DcxExpeditieResponse">
<wsdl:part name="DcxExpeditieResponse" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="DcxExpeditieServicePortType">
<wsdl:operation name="DcxExpeditieOperation">
<wsdl:input message="tns:DcxExpeditieRequest"/>
<wsdl:output message="tns:DcxExpeditieResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DcxExpeditieOperation">
<soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
<wsdl:input>
<soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://www.mycompany.nl/DcxExpeditieService/v1"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DcxExpeditieService">
<wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
<soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
When using this WSDL in soapui it results in the following input example:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:DcxExpeditieOperation>
<DcxExpeditie>
<v1:Expeditie>
<v1:tag1>?</v1:tag1>
<v1:tag2>?</v1:tag2>
</v1:Expeditie>
</DcxExpeditie>
</v1:DcxExpeditieOperation>
</soapenv:Body>
</soapenv:Envelope>
However, the original input format was:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.mycompany.nl/DcxExpeditieService/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:DcxExpeditie>
<v1:Expeditie>
<v1:tag1>?</v1:tag1>
<v1:tag2>?</v1:tag2>
</v1:Expeditie>
</v1:DcxExpeditie>
</soapenv:Body>
</soapenv:Envelope>
so with no DcxExpeditieOperation tag and with the v1 namespace in front of DcxExpeditie
Is this possible and if so, how can I accomplish this?
Try to change SOAP binding from rpc to document to remove DcxExpeditieOperation tag:
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
To fix the namespace issue refer DcxExpeditie element insted of type:
<wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
Updated WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:tns="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema targetNamespace="http://www.mycompany.nl/DcxExpeditieService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="DcxExpeditie" type="tns:DcxExpeditie"/>
<xs:element name="DcxExpeditieResponse" type="xs:string"/>
<xs:complexType name="DcxExpeditie">
<xs:sequence>
<xs:element name="Expeditie" type="tns:Expeditie"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Expeditie">
<xs:sequence>
<xs:element name="tag1" type="xs:string"/>
<xs:element name="tag2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="DcxExpeditieRequest">
<wsdl:part name="DcxExpeditie" element="tns:DcxExpeditie"/>
</wsdl:message>
<wsdl:message name="DcxExpeditieResponse">
<wsdl:part name="DcxExpeditieResponse" element="tns:DcxExpeditieResponse" />
</wsdl:message>
<wsdl:portType name="DcxExpeditieServicePortType">
<wsdl:operation name="DcxExpeditieOperation">
<wsdl:input message="tns:DcxExpeditieRequest"/>
<wsdl:output message="tns:DcxExpeditieResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DcxExpeditieServiceSOAP" type="tns:DcxExpeditieServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DcxExpeditieOperation">
<soap:operation soapAction="http://www.mycompany.nl/DcxExpeditieService/v1/DcxExpeditie"/>
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DcxExpeditieService">
<wsdl:port name="DcxExpeditieServiceSOAP" binding="tns:DcxExpeditieServiceSOAP">
<soap:address location="https://someserver.mycompany.nl/vbs/dcxexpeditie"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have a perl program that is accessing a soap server. when testing the soap server via SoapUI it works, but when using my perl program I get
Can't use an undefined value as an ARRAY reference at /Library/Perl/5.18/SOAP/WSDL.pm line 222.
Here is my perl script.
use SOAP::WSDL;
my $data = 'some data here';
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $client = SOAP::WSDL->new( 'wsdl' => "link_to_wsdl" );
my $result = $client->call('MyMethod', $data);
use Data::Dumper;
print Dumper($result);
Here is the WSDL
<?xml version="1.0"?>
<wsdl:definitions
name="Test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:APISoapServer"
targetNamespace="urn:APISoapServer"
>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:APISoapServer">
<xsd:element name="MyMethod">
<xsd:complexType>
<xsd:complexContent mixed="true">
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="operand1" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="MyMethodResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Confirmation" maxOccurs="unbounded">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="response" type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MYAPIRequest">
<wsdl:part name="MYAPIRequestPart" element="tns:MyMethod"/>
</wsdl:message>
<wsdl:message name="MYAPIResponse">
<wsdl:part name="MYAPIResponsePart" element="tns:MyMethodResponse"/>
</wsdl:message>
<wsdl:portType name="MYAPIServerPort">
<wsdl:operation name="MyMethod">
<wsdl:input name="MyMethodInput" message="tns:MYAPIRequest"/>
<wsdl:output name="MyMethodOutput" message="tns:MYAPIResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MYAPIServerBinding" type="tns:MYAPIServerPort">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="MyMethod">
<soap12:operation style="document" soapAction="urn:APISoapServer#MyMethod" />
<wsdl:input name="MyMethodInput">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="MyMethodOutput">
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MYAPIService">
<wsdl:port name="MYAPIPort" binding="tns:MYAPIServerBinding">
<soap12:address location="https://my.site.com/api/my_api_server.pl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have created a WSDL and a Mule SOAP proxy web service using the MuleSoft XML Only SOAP Web Service example. My application is working fine except for one issue: When the XSD is stored anywhere other than the root of the project, it will not resolve. I created folders of service and xsd inside /src/main/resources as shown in the example project, however when the service is invoked I receive the following error:
[[bpi.sfdcservices].connector.http.mule.default.receiver.02] org.apache.cxf.wstx_msv_validation.ResolvingGrammarReaderController: C:\Users\mmrg\MuleStudio\workspace\bpi.sfdcservices\xsd\sfdcServicesApiTypes.xsd (The system cannot find the path specified)
java.io.FileNotFoundException: C:\Users\mmrg\MuleStudio\workspace\bpisfdcservices\xsd\sfdcServicesApiTypes.xsd (The system cannot find the path specified)
The xsd is imported as:
<xs:import namespace="BPI/Types" schemaLocation="xsd/sfdcServicesApiTypes.xsd"/>
If I change this location to
<xs:import namespace="BPI/Types" schemaLocation="sfdcServicesApiTypes.xsd"/>
And place the xsd in the root of the project, the service executes normally.
The WSDL is able to be referenced in the class path/relative pathing.
<cxf:proxy-service namespace="BPI/sfdcServices/1.0" service="sfdcServices" payload="body" doc:name="SOAP" port="sfdcServicesHttpSoapEndpoint" wsdlLocation="service/sfdcServices.wsdl" validationEnabled="true"/>
From what I can see my project is set up the same as the Mule example. I do not see any specific mappings etc in their configuration. I'm suspecting there is something off about the way my WSDL/XSD is written since it behaves the same when I imported all of my project files into the example project, but cannot figure out the issue.
sfdcServices.wsdl:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="SFDCServices" targetNamespace="BPI/sfdcServices/1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="BPI/sfdcServices/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:btns="BPI/Types" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" >
<wsdl:documentation>Services for CRU operations in SFDC</wsdl:documentation>
<wsdl:types>
<xs:schema targetNamespace="BPI/sfdcServices/1.0" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="BPI/Types" schemaLocation="xsd/sfdcServicesApiTypes.xsd"/>
<xs:element name="querySFDCSingleRequest" type="btns:querySFDCSingleRequest"/>
<xs:element name="querySFDCSingleResponse" type="btns:querySFDCSingleResponse"/>
<xs:element name="updateSFDCSingleRequest" type="btns:updateSFDCSingleRequest"/>
<xs:element name="updateSFDCSingleResponse" type="btns:updateSFDCSingleResponse"/>
<xs:element name="createSFDCSingleRequest" type="btns:createSFDCSingleRequest"/>
<xs:element name="createSFDCSingleResponse" type="btns:createSFDCSingleResponse"/>
</xs:schema>
</wsdl:types>
<wsdl:documentation>Query for a single sObject</wsdl:documentation>
<wsdl:message name="querySFDCSingleRequestMsg">
<wsdl:part name="querySFDCSingleRequestPart" element="tns:querySFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="querySFDCSingleResponseMsg">
<wsdl:part name="querySFDCSingleResponsePart" element="tns:querySFDCSingleResponse"/>
</wsdl:message>
<wsdl:documentation>Update a single sObject</wsdl:documentation>
<wsdl:message name="updateSFDCSingleRequestMsg">
<wsdl:part name="updateSFDCSingleRequestPart" element="tns:updateSFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="updateSFDCSingleResponseMsg">
<wsdl:part name="updateSFDCSingleResponsePart" element="tns:updateSFDCSingleResponse"/>
</wsdl:message>
<wsdl:documentation>Create a single sObject</wsdl:documentation>
<wsdl:message name="createSFDCSingleRequestMsg">
<wsdl:part name="createSFDCSingleRequestPart" element="tns:createSFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="createSFDCSingleResponseMsg">
<wsdl:part name="createSFDCSingleResponsePart" element="tns:createSFDCSingleResponse"/>
</wsdl:message>
<wsdl:portType name="sfdcServicesSOAP">
<wsdl:operation name="querySFDCSingle">
<wsdl:input name="querySFDCSingleRequestInput" message="tns:querySFDCSingleRequestMsg"/>
<wsdl:output name="querySFDCSingleResponseOutput" message="tns:querySFDCSingleResponseMsg"/>
</wsdl:operation>
<wsdl:operation name="updateSFDCSingle">
<wsdl:input name="updateSFDCSingleRequestInput" message="tns:updateSFDCSingleRequestMsg"/>
<wsdl:output name="updateSFDCSingleResponseOutput" message="tns:updateSFDCSingleResponseMsg"/>
</wsdl:operation>
<wsdl:operation name="createSFDCSingle">
<wsdl:input name="createSFDCSingleRequestInput" message="tns:createSFDCSingleRequestMsg"/>
<wsdl:output name="createSFDCSingleResponseOutput" message="tns:createSFDCSingleResponseMsg"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="sfdcServicesSoapBinding" type="tns:sfdcServicesSOAP">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="querySFDCSingle">
<soap:operation soapAction="querySFDCSingle" style="document"/>
<wsdl:input name="querySFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="querySFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="updateSFDCSingle">
<soap:operation soapAction="updateSFDCSingle" style="document"/>
<wsdl:input name="updateSFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="updateSFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createSFDCSingle">
<soap:operation soapAction="createSFDCSingle" style="document"/>
<wsdl:input name="createSFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createSFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="sfdcServices">
<wsdl:port name="sfdcServicesHttpSoapEndpoint" binding="tns:sfdcServicesSoapBinding">
<soap:address location="http://localhost:8084/BPI/services/sfdcServices"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
sfdcServicesApiTypes.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="BPI/Types" targetNamespace="BPI/Types" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:complexType name="querySFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="queryFilterField" type="xs:string" nillable="false" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="queryCondition" type="ns1:queryCondition" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="querySFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="updateSFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="Id" type="xs:string" nillable="false"/>
<xs:element name="fieldUpdates" type="ns1:dataPair" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="updateSFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="createSFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="fieldUpdates" type="ns1:dataPair" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createSFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="dataPair">
<xs:sequence>
<xs:element name="fieldName" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="queryCondition">
<xs:sequence>
<xs:element name="queryField" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="operator" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
I am new to web services, I bought a book and started to learn from it, the WSDL is :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ttdev.com/ss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SimpleService" targetNamespace="http://ttdev.com/ss">
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:element name="concatRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="s1" type="xsd:string" />
<xsd:element name="s2" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="concatResponse" type="xsd:string">
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="concatRequest">
<wsdl:part element="tns:concatRequest" name="parameters"/>
</wsdl:message>
<wsdl:message name="concatResponse">
<wsdl:part element="tns:concatResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="concat">
<wsdl:input message="tns:concatRequest"/>
<wsdl:output message="tns:concatResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSOAP" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="concat">
<soap:operation soapAction="http://ttdev.com/ss/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<wsdl:port binding="tns:SimpleServiceSOAP" name="p1">
<soap:address location="http://localhost:8080/ss/p1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I run the SimpleService_P1_Server, it s working, but when I run the client :
SimpleService_P1_Client I got this exeption :
Apr 8, 2012 9:51:47 AM com.ttdev.ss.SimpleService_Service <clinit>
INFO: Can not initialize the default wsdl from src/main/resources/SimpleService.wsdl
Exception in thread "main" javax.xml.ws.WebServiceException: Port {http://ttdev.com/ss}p1 not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:328)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.ttdev.ss.SimpleService_Service.getP1(SimpleService_Service.java:56)
at com.ttdev.ss.SimpleService_P1_Client.main(SimpleService_P1_Client.java:49)
Thanks, your help is appreciated.
I also faced similar issue some time back. You may want to use a prefix "file:" before "src/main/resources". Here is the resultant code:
WSDLToJava.main(new String[] { "-client", "-d", "src/main/java",
"file:src/main/resources/SimpleService.wsdl" });
I am writing a web service starting with writing the WSDL. I have been generating server-side skeleton code using wsimport and then writing my own implementing class. I'm running the web service on an Axis2 server. When using soapUI, the SOAP messages coming to and from the service look fine, but when using a web service client, I'm getting null in the client-side stubs. I've heard that this could be a namespace issue, but I see anything wrong. Here is my copy of the WSDL. Any help would be appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://test.sa.lmco.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://test.sa.lmco.com">
<!-- **************** -->
<!-- ** Types ** -->
<!-- **************** -->
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.sa.lmco.com">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNode">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNodeResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="resultNode" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildren">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="parentNodeId" minOccurs="1" maxOccurs="1" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildrenResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="childNodes" minOccurs="0" maxOccurs="unbounded" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="TaxonomyNode">
<xs:sequence>
<xs:element name="taxonomyId" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="LCD">
<xs:sequence>
<xs:element name="language" type="xs:string" />
<xs:element name="content" type="xs:string" />
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!-- ***************** -->
<!-- ** Messages ** -->
<!-- ***************** -->
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns:sayHello"/>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns:sayHelloResponse"/>
</wsdl:message>
<wsdl:message name="getTaxonomyNodeRequest">
<wsdl:part name="parameters" element="ns:getTaxonomyNode" />
</wsdl:message>
<wsdl:message name="getTaxonomyNodeResponse">
<wsdl:part name="parameters" element="ns:getTaxonomyNodeResponse" />
</wsdl:message>
<wsdl:message name="getChildrenRequest">
<wsdl:part name="parameters" element="ns:getChildren" />
</wsdl:message>
<wsdl:message name="getChildrenResponse">
<wsdl:part name="parameters" element="ns:getChildrenResponse" />
</wsdl:message>
<!-- ******************* -->
<!-- ** PortTypes ** -->
<!-- ******************* -->
<wsdl:portType name="HelloWSPortType">
<wsdl:operation name="sayHello">
<wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello"/>
<wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<wsdl:input message="ns:getTaxonomyNodeRequest" wsaw:Action="urn:getTaxonomyNode" />
<wsdl:output message="ns:getTaxonomyNodeResponse" wsaw:Action="urn:getTaxonomyNodeResponse" />
</wsdl:operation>
<wsdl:operation name="getChildren">
<wsdl:input message="ns:getChildrenRequest" wsaw:Action="urn:getChildren" />
<wsdl:output message="ns:getChildrenResponse" wsaw:Action="urn:getChildrenResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- ****************** -->
<!-- ** Bindings ** -->
<!-- ****************** -->
<wsdl:binding name="HelloWSServiceSoap11Binding" type="ns:HelloWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<soap:operation soapAction="urn:getTaxonomyNode" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getChildren">
<soap:operation soapAction="urn:getChildren" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- **************** -->
<!-- ** Service ** -->
<!-- **************** -->
<wsdl:service name="HelloWS">
<wsdl:port name="HelloWSServiceHttpSoap11Endpoint" binding="ns:HelloWSServiceSoap11Binding">
<soap:address location="http://162.16.129.25:9090/axis2/services/HelloWS"/>
</wsdl:port>
</wsdl:service>
I was having the same problem with Soap web services, that is I am getting null response. I found the reason is I need to add appropriate Header fields in the request: Say for example - content-type, content-encoding, etc., depending on the service written. You better check with the one who has written the web services
This could be because of separate WSDL files.
If you specify WSDL separately in META-INF then AXIS2 passes arguments of the webservice as an OMElement.
I.e. if you have used other datatypes as arguments in service API and you have a WSDL in META-INF then while calling Service the parameters are OMElement not String / int or etc...