SudsLibrary Robot Framework : incorrect WSDL parsing - web-services

It seems that my request SOAP object is being parsed incorrectly by SudsLibrary 0.8. Given that I have the following complex type:
<complexType name="getSchoolRequest">
<sequence>
<element name="school_name" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="school_type" type="xsd:string"/>
<element name="requestee" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="requestee_age" type="xsd:int"/>
</sequence>
</complexType>
<element name="getSchoolRequest" type="impl:getSchoolRequest"/>
I generate the SOAP message with the following code:
Check SOAP Service Functional
create soap client ${WSDL_ENDPOINT}
${mySchoolRequest}= create wsdl object getSchoolRequest
${mySchoolResponse}= call soap method getSchoolResponse ${mySchoolRequest}
As a result, I get this SOAP message as the final creation:
<SOAP-ENV:Envelope xmlns:ns0="http://jaxws.webservices.my.srv/schemas" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:getSchoolRequest>
<ns0:school_name>
<ns0:school_name/>
<ns0:requestee/>
</ns0:school_name>
<ns0:requestee/>
</ns0:getSchoolRequest>
</ns1:Body>
</SOAP-ENV:Envelope>
What I expect to see instead is something like this:
<SOAP-ENV:Envelope xmlns:ns0="http://jaxws.webservices.my.srv/schemas" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:getSchoolRequest>
<ns0:school_name/>
<ns0:school_type/>
<ns0:requestee/>
<ns0:requestee_age/>
</ns0:getSchoolRequest>
</ns1:Body>
</SOAP-ENV:Envelope>
SoapUI confirms that the version I expect is the one that generates. Am I missing something with SudsLibrary in making this generation accurate?

Related

How #WebResult annotation works in JAX-WS

I'm trying to create Jax-ws WebServices. But stuck with this behaviour of JAX-WS 2.2.
I wrote the SEI class in the following way
#WebService
#SOAPBinding(parameterStyle=ParameterStyle.WRAPPED,use=Use.LITERAL,style=Style.DOCUMENT)
public class WebServicesServlet{
#WebMethod
public GetServerTimeProperty getServerTimeProperties(){
return new GetServerTimeProperty();
}
}
The generated wsdl for the above SEI is as follows:
<types>
<xsd:schema>
<xsd:import namespace="http://soapCl.test/" schemaLocation="WebServicesService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="getServerTimeProperties">
<part name="parameters" element="tns:getServerTimeProperties"> </part>
</message>
<message name="getServerTimePropertiesResponse">
<part name="parameters" element="tns:getServerTimePropertiesResponse"> </part>
</message>
And the XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapCl.test/" version="1.0" targetNamespace="http://soapCl.test/">
<xs:element name="getTimeProperties" type="tns:getServerTimeProperties"/>
<xs:element name="getTimePropertiesResponse" type="tns:getServerTimePropertiesResponse"/>
<xs:complexType name="getServerTimeProperties">
<xs:sequence/>
</xs:complexType>
**<xs:complexType name="getServerTimePropertiesResponse">**
<xs:sequence>
**<xs:element name="return" type="tns:getServerTimeProperty" minOccurs="0"/>**
</xs:sequence>
</xs:complexType>
<xs:complexType name="getServerTimeProperty">
<xs:sequence>
<xs:element name="dayLightSavingHours" type="xs:int"/>
<xs:element name="observesDayLightSavings" type="xs:boolean"/>
<xs:element name="timeZoneDisplayName" type="xs:string"/>
<xs:element name="timeZoneId" type="xs:string"/>
<xs:element name="timeZoneValue" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
SOAP Response :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:getServerTimePropertiesResponse xmlns:dlwmin="http://soapCl.test/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<GetServerTimeProperty>
<dayLightSavingHours>0</dayLightSavingHours>
<observesDayLightSavings>false</observesDayLightSavings>
</GetServerTimeProperty>
</dlwmin:getServerTimePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
I've tried to generate stubs using wsimport and this is what I could observe in the generated port class
#WebMethod
**#WebResult(targetNamespace = "")**
#RequestWrapper(localName = "getServerTimeProperties", targetNamespace = "http://soapCl.test/", className = "soapCl.test.GetServerTimeProperties")
#ResponseWrapper(localName = "getServerTimePropertiesResponse", targetNamespace = "http://soapCl.test/", className = "soapCl.test.GetServerTimePropertiesResponse")
#Action(input = "http://soapCl.test/WsSessionEJBEndPoint/getServerTimePropertiesRequest", output = "http://soapCl.test/WsSessionEJBEndPoint/getServerTimePropertiesResponse")
public GetServerTimeProperty getServerTimeProperties();
I'm curious to Know why is the WebResult name different in wsdl as "return" and in soap Response as "GetServerTimeProperty" and in generated stub as "".
Also If I dont annotate the Webmethod with #WebResult(name="GetServerTimeProperty"), my stub-generated client response is null.
If I annotate my webmethod with #WebResult(name="GetServerTimeProperty"), my soapResponse is looking as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:getServerTimePropertiesResponse xmlns:ns2="http://soapCl.test/">
<return>
<dayLightSavingHours>0</dayLightSavingHours>
<observesDayLightSavings>false</observesDayLightSavings>
</return>
</ns2:getServerTimePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
Is #WebResult(name) is mandatory in jax-ws? I'm curios to Know how this webresult annotation is making a difference in soap response and client response.
Is is that the name should be unique for every "operationName"+"Respone" element ? My wsdl has many elements with same name as
Please Suggest on this why the WebResult name returning soap response as null if we dont annotate
I Further ruled out this
1.When two webmethods methods have same #WebResult(name="A"), the soapResponse result name differs for two methods when I mention
<wsdl-file>web-inf/wsdl/WebService.wsdl</wsdl-file>
explicitly in webservices.xml.
2.The SoapResponse return name is same when I remove the <wsdl-file> entry in webservices.xml. Not sure how wsdl-file tag is making the difference.

Raw SOAP Magento Requests

Im trying to find information on how to post data to Magento 1.9 SOAP API using PAW / POSTMAN.
Most importantly Im trying to find out how to add filters into the requests
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:salesOrderList soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<sessionId xsi:type="xsd:string">alreadydefinedandworking</sessionId>
</urn:salesOrderList>
</soapenv:Body>
</soapenv:Envelope>
Im currently using Soap UI to do my tasks but im stuck on how to add filters into the SOAP packets so I can get data out of Magento.
Is there any location online with Gists for the basics on connecting to Magento using the XML packets? Or if anyone knows how to add the filter in for incremental_id that would be super nice of you
request nodes differ depending on what type of soap API you use in Magento.
There are:
Soap v1
Soap v2
WS-I
if you use the most compatible WSI mode - request param definition looks like this:
<xsd:element name="salesOrderListRequestParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="filters" type="typens:filters"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
where filters ns is:
<xsd:complexType name="filters">
<xsd:sequence>
<xsd:element name="filter" type="typens:associativeArray" minOccurs="0"/>
<xsd:element name="complex_filter" type="typens:complexFilterArray" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
both values are array-objects with key value pairs.
For more info see the code in API Helper, method: parseFilters() and _parseComplexFilter if you use conditions in filter.
some example (Soap_v2):
<ns1:salesOrderListRequestParam>
<sessionId>your sesion id</sessionId>
<filters>
<filter>
<complexObjectArray>
<key>increment_id</key>
<value>12345</value>
</complexObjectArray>
</filter>
</filters>
</ns1:salesOrderListRequestParam>

XSLT stylesheet for creating an XML Schema Definition

My input data looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:queryResponse xmlns:ns1="http://abc.com/">
<ns1:result>
<ns1:records xmlns:ns2="http://def.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:Account">
<ns2:Id>2c</ns2:Id>
<ns2:Number>A722</ns2:AccountNumber>
</ns1:records>
</ns1:result>
</ns1:queryResponse>
I need to write a stylesheet which will create XML of the format:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Account">
<xsd:sequence>
<xsd:element minOccurs="0" name="Id" type="xsd:string"/>
<xsd:element minOccurs="0" name="Number" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
The stylesheet should be able to create this XML?
The fields are also dynamically changing, so the stylesheet has to be generic so that it can extract the element name and value from the XML and create the output XML.

Importing xsd into wsdl

This is my current configuration:
XSD
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://stock.com/schemas/services/stock"
xmlns:tns="http://stock.com/schemas/services/stock"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="http://stock.com/schemas/services/stock">
<xsd:element name="Stock">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ticker" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" nillable="true" type="Quote"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Quote">
........
</xsd:complexType>
.......
<xsd:element name="gethighBetaStockResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="stock" ref="Stock" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
WSDL
<?xml version="1.0" encoding="UTF-8"?><definitions targetNamespace="http://stock.com/schemas/services/stock/wsdl"
.....xmlns:external="http://stock.com/schemas/services/stock"
<import namespace="http://stock.com/schemas/services/stock" location="Stock.xsd" />
<message name="getStockQuoteResp">
<part name="parameters" element="external:getStockQuoteResponse" />
</message>
However,the moment ref="Stock" is changed to type="Stock",the wsdl2java starts giving
Type {http://stock.com/schemas/services/stock}Stock is referenced but not defined.
Somehow it seems a clash between wsdl and xsd imports - but I just cant resolve it.Help is appreciated.
You have a couple of problems here.
First, the XSD has an issue where an element is both named or referenced; in your case should be referenced.
Change:
<xsd:element name="stock" ref="Stock" minOccurs="1" maxOccurs="unbounded"/>
To:
<xsd:element name="stock" type="Stock" minOccurs="1" maxOccurs="unbounded"/>
And:
Remove the declaration of the global element Stock
Create a complex type declaration for a type named Stock
So:
<xsd:element name="Stock">
<xsd:complexType>
To:
<xsd:complexType name="Stock">
Make sure you fix the xml closing tags.
The second problem is that the correct way to reference an external XSD is to use XSD schema with import/include within a wsdl:types element. wsdl:import is reserved to referencing other WSDL files. More information is available by going through the WS-I specification, section WSDL and Schema Import. Based on WS-I, your case would be:
INCORRECT: (the way you showed it)
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://stock.com/schemas/services/stock/wsdl"
.....xmlns:external="http://stock.com/schemas/services/stock"
<import namespace="http://stock.com/schemas/services/stock" location="Stock.xsd" />
<message name="getStockQuoteResp">
<part name="parameters" element="external:getStockQuoteResponse" />
</message>
</definitions>
CORRECT:
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://stock.com/schemas/services/stock/wsdl"
.....xmlns:external="http://stock.com/schemas/services/stock"
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://stock.com/schemas/services/stock" schemaLocation="Stock.xsd" />
</schema>
</types>
<message name="getStockQuoteResp">
<part name="parameters" element="external:getStockQuoteResponse" />
</message>
</definitions>
SOME processors may support both syntaxes. The XSD you put out shows issues, make sure you first validate the XSD.
It would be better if you go the WS-I way when it comes to WSDL authoring.
Other issues may be related to the use of relative vs. absolute URIs in locating external content.
import vs. include
The primary purpose of an import is to import a namespace. A more common use of the XSD import statement is to import a namespace which appears in another file. You might be gathering the namespace information from the file, but don't forget that it's the namespace that you're importing, not the file (don't confuse an import statement with an include statement).
Another area of confusion is how to specify the location or path of the included .xsd file: An XSD import statement has an optional attribute named schemaLocation but it is not necessary if the namespace of the import statement is at the same location (in the same file) as the import statement itself.
When you do chose to use an external .xsd file for your WSDL, the schemaLocation attribute becomes necessary. Be very sure that the namespace you use in the import statement is the same as the targetNamespace of the schema you are importing. That is, all 3 occurrences must be identical:
WSDL:
xs:import namespace="urn:listing3" schemaLocation="listing3.xsd"/>
XSD:
<xsd:schema targetNamespace="urn:listing3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Another approach to letting know the WSDL about the XSD is through Maven's pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-sources-xmlbeans</id>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<version>2.3.3</version>
<inherited>true</inherited>
<configuration>
<schemaDirectory>${basedir}/src/main/xsd</schemaDirectory>
</configuration>
</plugin>
You can read more on this in this great IBM article. It has typos such as xsd:import instead of xs:import but otherwise it's fine.

WSDL: No element type is defined for message

I'm creating a service orchestration using Eclipse BPEL Designer plugin and i have a problem with the WSDL file that it generates automatically.
Here is the WSDL:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.invocation.import" xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop" xmlns:wsdl="http://services.lolsystem.it" name="ImportOrchestration" targetNamespace="http://ws.invocation.import">
<plnk:partnerLinkType name="ImportType">
<plnk:role name="ImportRole" portType="wsdl:ImportServicePortType"/>
</plnk:partnerLinkType>
<import location="ImportModule.wsdl" namespace="http://services.italsystem.it"/>
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.invocation.import">
<element name="ImportOrchestrationRequest" type="tns:ImportOrchestrationReqType">
</element>
<element name="singleEntry">
<complexType>
<sequence>
<element minOccurs="0" name="name" nillable="true" type="string"/>
<element minOccurs="0" name="content" nillable="true" type="base64Binary"/>
</sequence>
</complexType>
</element>
<element name="ImportOrchestrationResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
<complexType name="ImportOrchestrationReqType">
<sequence minOccurs="1" maxOccurs="unbounded">
<element name="file" type="tns:SingleFile"></element>
</sequence>
</complexType>
<complexType name="SingleFile">
<sequence>
<element name="name" type="string"></element>
<element name="content" type="base64Binary"></element>
</sequence>
</complexType>
</schema>
</types>
<message name="ImportOrchestrationRequestMessage">
<part name="payload" type="tns:ImportOrchestrationReqType"/>
</message>
<message name="ImportOrchestrationResponseMessage">
<part element="tns:ImportOrchestrationResponse" name="payload"/>
</message>
<!-- portType implemented by the ImportOrchestration BPEL process -->
<portType name="ImportOrchestration">
<operation name="process">
<input message="tns:ImportOrchestrationRequestMessage"/>
<output message="tns:ImportOrchestrationResponseMessage"/>
</operation>
</portType>
<plnk:partnerLinkType name="ImportOrchestration">
<plnk:role name="ImportOrchestrationProvider" portType="tns:ImportOrchestration"/>
</plnk:partnerLinkType>
<binding name="ImportOrchestrationBinding" type="tns:ImportOrchestration">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="process">
<soap:operation soapAction="http://ws.invocation.import/process"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ImportOrchestration">
<port binding="tns:ImportOrchestrationBinding" name="ImportOrchestrationPort">
<soap:address location="http://localhost:8080/ode/processes/ImportOrchestration"/>
</port>
</service>
</definitions>
Now, the problem is that Eclipse for Eclipse validator the WSDL is well formed.
I'm using Apache ODE as a BPEL engine, who is based on Axis2.
The problemi is that Axis engine give me an error when i try to deploy my BPEL proces, and it is:
"No element type is defined for message ImportOrchestrationRequestMessage"
Does someone can give me some advice to understand this error and how to correct it?
thanks in advance :)
Can you try following
<message name="ImportOrchestrationRequestMessage">
<part name="payload" element="tns:ImportOrchestrationRequest"/>
</message>
The problem is your binding is document literal, in that case the message part should be configured by using "element" rather than the "type"
HTH