I have a C# client which produces the .NET SOAP envelope below, which works against a C# ASMX SOAP web service. However we have a Java Client calling into our service which is producing the Java envelope specified below. The main difference between the envelopes is that some values are serialised as attributes in the java client envelope rather than as XML element nodes in the C# client envelope. The java client is using AXIS WSDL2Java to generate their client. Would anyone know what I would need to tell the Java developers so they may generate the correct soap envelope for the example shown.
Kind Regards
Working SOAP Envelope Captured from C# Client
<?xml version="1.0" encoding="utf-8"?>
<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">
<soap:Body>
<getDocumentPageRequest xmlns="urn:mycorp-com:MyApp.Schema.DocumentEnquiry.Messages.v01">
<header xmlns="urn:mycorp-com:MyApp.Schema.Common.Types.v01">
<extensions />
<corelationIdentifier>41edebfb-fffd-44f8-94e9-be043e1dad48</corelationIdentifier>
</header>
<securityToken xmlns="urn:mycorp-com:MyApp.Schema.Common.Types.v01">
<Value>218FD85D</Value>
</securityToken>
<documentIdentifier>15236HDFG000005</documentIdentifier>
<pageNumber>1</pageNumber>
</getDocumentPageRequest>
</soap:Body>
</soap:Envelope>
Java SOAP Envelope - Not working with web-service
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getDocumentPageRequest
documentIdentifier="15236HDFG000005"
pageNumber="1"
xmlns="urn:mycorp-com:MyApp.Schema.DocumentEnquiry.Messages.v01">
<ns1:header corelationIdentifier="" xmlns:ns1="urn:mycorp-com:MyApp.Schema.Common.Types.v01">
<ns1:extensions/>
</ns1:header>
<ns2:securityToken xmlns:ns2="urn:mycorp-com:MyApp.Schema.Common.Types.v01">218FD85D</ns2:securityToken>
</getDocumentPageRequest>
</soapenv:Body>
</soapenv:Envelope>
Edited:: Added in WSDL as requested.
Sample WSDL and XSD Extract
Below is a sample of the WSDL generated and an extract of the XSD that it imports for the message type. I can see in this that the XML has attributes, which is what the AXIS WSDL2Java is generating, but the C# proxy and web-service is expecting XML nodes. I think this means the way the C# services is implemented is different somehow or other than the schema it is defined against. This is confusing...
<!-- WSDL Extract -->
<message name="getDocumentPageIn">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="messagePart" element="import0:getDocumentPageRequest" />
</message>
<message name="getDocumentPageOut">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="messagePart" element="import0:getDocumentPageResponse" />
</message>
<!-- import0 XSD extract -->
<xs:element name="getDocumentPageRequest">
<xs:complexType>
<xs:complexContent>
<xs:extension base="MyApp:request">
<xs:attribute name="documentIdentifier" type="xs:string" use="required"/>
<xs:attribute name="pageNumber" type="xs:short" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
Thanks for taking the time to review this, but I found the actual problem.
It turns out the C# code that was being generated for the types for the web-service and proxy was missing an [XmlAttribute] attribute in the code for each attribute defined in the XML. This caused the XmlSerializer to flatten the properties on the class to elements rather than keeping them as attributes.
Related
So a guy send me a xsd and xpdl and told me to make requests to a SOAP gateway using this in Java.
What am I supposed to do with this? Load it or something? Can someone explain?
Any advice?
You should receive a WSDL as well. Using WSDL then you can generate soap client in java.
Soap client is like a library which act as local set of classes and methods. You can use those to call operations to execute on SOAP gateway. Its like you are calling a function locally but when executed, it will run on the SOAP gateway (remote server) where this function logic is implemented and hosted.
wsdl contains SOAP endpoints and xsd for data validation and description. Suppose you have a SOAP request like this
<message name = "SayHelloRequest">
<part name = "firstName" type = "xsd:string"/>
</message>
<message name = "SayHelloResponse">
<part name = "greeting" type = "xsd:string"/>
</message>
<portType name = "Hello_PortType">
<operation name = "sayHello">
<input message = "tns:SayHelloRequest"/>
<output message = "tns:SayHelloResponse"/>
</operation>
</portType>
here SayHelloRequest is request definition and SayHelloResponse is response defination. and Now suppose you have an Java Plain Object and then you need to define this on XSD like below code
<xs:element name="Person">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
you can define in XSD datatypes and its validation.
For simplicity xsd validate document and metadata anotherway WSDL is to describe the webservice location and operations. you can generate java classes from wsdl and yu can follow this link
https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jst.ws.cxf.doc.user%2Ftasks%2Fcreate_client.html
Im triying to implement a simple BPEL process that should be able to accept as an input an element defined in an external XSD.
Im using Eclipse Oxigen.2 Release (4.7.2) and the Eclipse BPEL designer 1.05 Final, also i'm running the BPEL process in Apache ODE Server 1.3.7.
To achieve this im importing the XSD in the BPEL generated WSDL, but when i include this tag the apache ODE Console doesnt show the process if i quit the import tag the process is showed in the console and runs correctly.
As BPEL2.0 is based in WSDL1.1 i was following the WSDL1.1 specification in the Authoring Style part, but it seems to be an error in the example, because they use the wsdl:import to import a XSD. Trying to import the XSD in this way raise a validation error in eclipse.
I found this answer that points to this link that states the error in WSDL1.1 specification:
Some examples in WSDL 1.1 incorrectly show the WSDL import statement
being used to import XML Schema definitions. The Profile clarifies use
of the import mechanisms to keep them consistent and confined to their
respective domains. Imported schema documents are also constrained by
XML version and encoding requirements consistent to those of the
importing WSDL documents.
R2001 A DESCRIPTION MUST only use the WSDL "import" statement to
import another WSDL description.
R2803 In a DESCRIPTION, the namespace attribute of the wsdl:import
MUST NOT be a relative URI.
R2002 To import XML Schema Definitions, a DESCRIPTION MUST use the XML
Schema "import" statement.
R2003 A DESCRIPTION MUST use the XML Schema "import" statement only
within the xsd:schema element of the types section.
R2004 In a DESCRIPTION the schemaLocation attribute of an xsd:import
element MUST NOT resolve to any document whose root element is not
"schema" from the namespace "http://www.w3.org/2001/XMLSchema".
R2009 An XML Schema directly or indirectly imported by a DESCRIPTION
MAY include the Unicode Byte Order Mark (BOM).
R2010 An XML Schema directly or indirectly imported by a DESCRIPTION
MUST use either UTF-8 or UTF-16 encoding.
R2011 An XML Schema directly or indirectly imported by a DESCRIPTION
MUST use version 1.0 of the eXtensible Markup Language W3C
Recommendation.
So with the above information, rigth now i have:
1. XSD Sxhema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ccts="urn:un:unece:uncefact:documentation:2"
targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="2.1">
<!-- ===== Imports ===== -->
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
schemaLocation="../common/UBL-CommonAggregateComponents-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
schemaLocation="../common/UBL-CommonBasicComponents-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
schemaLocation="../common/UBL-CommonExtensionComponents-2.1.xsd"/>
<!-- ===== Element Declarations ===== -->
<xsd:element name="OrderCancellation" type="OrderCancellationType">
<xsd:annotation>
<xsd:documentation>This element MUST be conveyed as the root element in any instance document based on this Schema expression</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- ===== Type Definitions ===== -->
<xsd:complexType name="OrderCancellationType">
<xsd:annotation>
<xsd:documentation>
<ccts:Component>
<ccts:ComponentType>ABIE</ccts:ComponentType>
<ccts:DictionaryEntryName>Order Cancellation. Details</ccts:DictionaryEntryName>
<ccts:Definition>A document used to cancel an entire Order.</ccts:Definition>
<ccts:ObjectClass>Order Cancellation</ccts:ObjectClass>
</ccts:Component>
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="cbc:IssueDate" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
<ccts:Component>
<ccts:ComponentType>BBIE</ccts:ComponentType>
<ccts:DictionaryEntryName>Order Cancellation. Issue Date. Date</ccts:DictionaryEntryName>
<ccts:Definition>The date, assigned by the sender, on which this document was issued.</ccts:Definition>
<ccts:Cardinality>1</ccts:Cardinality>
<ccts:ObjectClass>Order Cancellation</ccts:ObjectClass>
<ccts:PropertyTerm>Issue Date</ccts:PropertyTerm>
<ccts:RepresentationTerm>Date</ccts:RepresentationTerm>
<ccts:DataType>Date. Type</ccts:DataType>
</ccts:Component>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="cbc:IssueTime" minOccurs="0" maxOccurs="1">
<xsd:annotation>
...
</xsd:annotation>
</xsd:element>
<xsd:element ref="cbc:Note" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
...
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
2. Generated WSDL of BPEL Process
<?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://br.ufsc.das.ubl"
xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop"
xmlns:wsdl="http://service.endpoint.br.ufsc.das/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="OrderingUBL"
targetNamespace="http://br.ufsc.das.ubl">
<!--
Added XSD namespace
xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
-->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TYPE DEFINITION - List of types participating in this BPEL process
The BPEL Designer will generate default request and response types
but you can define or import any XML Schema type and use them as part
of the message types.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="IntegratorEndPoint_PLT">
<plnk:role name="IntegratorEndPoint_Role" portType="wsdl:IntegrationEndPointImpl"/>
</plnk:partnerLinkType>
<import location="file:/C:/my/path/IntegrationEndpoint.wsdl" namespace="http://service.endpoint.br.ufsc.das/"/>
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://br.ufsc.das.ubl">
<!--Importing the XSD file-->
<import
namespace="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
schemaLocation="file:/C:/UBL-2.1/xsd/maindoc/UBL-OrderCancellation-2.xsd" />
<element name="OrderingUBLRequest">
<complexType>
<sequence>
<!-- Defining the Type of element OrderingUBLRequest
to be the element in the imported XSD
-->
<element name="input" type="ubl:OrderCancellationType" />
</sequence>
</complexType>
</element>
<element name="OrderingUBLResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MESSAGE TYPE DEFINITION - Definition of the message types used as
part of the port type defintions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<message name="OrderingUBLRequestMessage">
<part element="tns:OrderingUBLRequest" name="payload"/>
</message>
<message name="OrderingUBLResponseMessage">
<part element="tns:OrderingUBLResponse" name="payload"/>
</message>
<!--
.
. All the other WSDL tags
.
-->
</definitions>
QUESTION
Am I missing something importing the XSD in the WSDL BPEL file and run it in Apache ODE?
I have a WSDL file which also contains all types used in it (via <wsdl:types>
tag). When defining the types, I have something like this:
<wsdl:definitions name="service"
targetNamespace="http://www.xxx.yyy/reg/definitions" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tax="http://www.xxx.yyy/reg/definitions" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
.............
<xs:complexType name="CompanyName">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="ShortName" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="Language" type="tax:LanguageType" use="required"/>
<xs:assert test="ShortName or #Language != 'Language1'"/>
</xs:complexType>
.............
</wsdl:definitions>
Unfortunately, it doesn't work giving the following exception when I try to start the application on Tomcat:
javax.xml.ws.WebServiceException: org.xml.sax.SAXParseException; s4s-elt-invalid-content.1: The content of 'CompanyName' is invalid. Element 'assert' is invalid, misplaced, or occurs too often.
The WSDL version is 1.2 and I don't know which version of xsd it uses when types are described in it, so I don't know if it is a xsd version (1.0 vs. 1.1) issue or something else.
Can someone help me in finding the real issue?
EDIT: I have added the header of the wsdl.
I have added the version attribute (version="1.1") to <xs:schema>
definition but that didn't help either:
<xs:schema targetNamespace="http://www.xxx.yyy/reg/definitions" elementFormDefault="qualified" version="1.1">
Looks like assertions were introduced with XML Schema v1.1 when the XMLSchema definition moved over to w3.org.
Sample header:
<wsdl:description
targetNamespace="http://www.w3.org/2002/ws/sawsdl/spec/wsdl/order#"
xmlns="http://www.w3.org/2002/ws/sawsdl/spec/wsdl/order#"
xmlns:wsdl="http://www.w3.org/ns/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sawsdl="http://www.w3.org/ns/sawsdl">
I'm trying to make a new version of a server that previously used Axis 1.4 to respond to SOAP RPC requests using Spring-WS. I have a few of the RPC calls working, but I'm stuck trying to satisfy a request that expects a SOAP body that looks like this:
<rpcCallResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<responseElement soapenc:arrayType="xsd:string[5]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<responseElement xsi:type="xsd:string">val1</responseElement>
<responseElement xsi:type="xsd:string">val2</responseElement>
<responseElement xsi:type="xsd:string">val3</responseElement>
<responseElement xsi:type="xsd:string" xsi:nil="true"/>
<responseElement xsi:type="xsd:string" xsi:nil="true"/>
</responseElement>
</rpcCallResponse>
I'm struggling to write the XML schema for this, and to get the JAXB marshaller to shove the xsi:type annotations into the response.
What's the correct XML schema to use/set of annotations to use to get this to marhsal (Java -> XML) correctly?
One solution I found that works for getting the arrayType added is to, instead of deriving from the http://schemas.xmlsoap.org/soap/encoding/ schema, use a custom schema of the form:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.xmlsoap.org/soap/encoding/"
elementFormDefault="qualified">
<xs:attribute name="arrayType" type="xs:QName" />
</xs:schema>
...which replaces the type of the arrayType attribute with an xs:QName (vs. the actual type, which is just an xs:string). The advantage of using a QName seems to be that JAXB will take the QName's namespace and shove it onto the element when serialization happens -- which was the main blocker on getting a working schema above.
The schema for above now looks something like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:encoding="http://schemas.xmlsoap.org/soap/encoding/"
targetNamespace="http://foo.com/bar"
elementFormDefault="qualified">
<xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="soapenc.xsd" />
<xs:element name="rpcCallResponse">
<xs:complexType>
<xs:element name="responseElement">
<xs:complexType>
<xs:sequence>
<xs:element name="responseElement" maxOccurs="5" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:attribute ref="soapenc:arrayType" />
</xs:complexType>
</xs:element>
</xs:schema>
I have Java WebService code in my eclipse. I have used #WebService #Webmethod, #XmlElements, #XmlType, #XmlAccessorType
Now I am generating wsdl using java2ws command from cxf framework. Here is the command
F:\....\code\java2wsdl>java2ws -o CustomerVxRR.wsdl -d <myOutputDir> -wsdl -cp <myClassesFolder> <ServiceImpl class>
my wsdl file contqins agr0 as name which I do not want because when I am importing it to SoapUI. It is adding tag around the field.
Here is wsdl part with arg0
<xs:schema ..... >
<xs:complexType name="myServiceMethodName">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:ServiceInputClassName"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceInputClassName">
<xs:sequence>
<xs:element minOccurs="0" name="EmpID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xz:schema>
Here is the request object which is generated in SOAPUI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://customeroffer.manage.ws.hello.my.com/">
<soapenv:Header/>
<soapenv:Body>
<cus:myServiceMethodName>
<!--Optional:-->
<arg0>
<EmpID >123456</EmpID>
</arg0>
</cus:myServiceMethodName>
</soapenv:Body>
</soapenv:Envelope>
If I remove tag I get this response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"", local:"EmpID"). Expected elements are <{}empid></faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I do not want to keep arg0 in the request XML
I just fixed it after some research of my own code. The only thing which is required to change <arg0> is that we need to used #WebParam annotation to declare custome name instead of "arg0".
For example:
my service name is getEmpDetail and EmpID is the input parameter to the service then here is the declaration required in the service impl class:
public Emp getEmpDetail(#WebParam(name="EmpDetail") String EmpId)
after generatingfrom WSDL the request XML will look like below
<ns:getEmpDetail>
<EmpDetail>
<EmdID>?</EmpID>
</EmpDetail>
<ns:getEmpDetail>