WSDL file for Apache CXF with "any xml" body - soap

Background: I'm developing web-service which communicates over WS-Management protocol. The original WSDL from here http://schemas.xmlsoap.org/ws/2005/06/management/wsman.wsdl looks like:
<xs:complexType name="SampleResourceType">
<xs:sequence>
<xs:element name="PropertyA" type="xs:string"/>
<xs:element name="PropertyB" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SampleResource" type="tns:SampleResourceType"/>
<wsdl:message name="PutMessage">
<wsdl:part name="Body" element="tns:SampleResource"/>
</wsdl:message>
And this WSDL works well with Apache CXF 2.4.0.
My goal:
Replace SampleResource definition with other to let operation handle any resource(XML). I'd like to create WSDL file for operation which SOAP output will look like:
<soap:Envelope>
<soap:Body>
<SomeXmlDocument></SomeXmlDocument>
</soap:Body>
</soap:Envelope>
And SomeXmlDocument means here any XML document defined in runtime.
The problem now CXF always puts predefined name from WSDL.
I'll show on examples:
I'm using following command: wsdl2java.bat -fe jaxws21 -d gen -exsh true -verbose file.wsdl
If I use wsdl:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" element="tns:CIMObject"/>
</wsdl:message>
The output looks like:
<soap:Body>
<ns8:CIMObject>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</ns8:CIMObject>
</soap:Body>
If I use:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" type="tns:CIMObjectType"/>
</wsdl:message>
Output looks like:
<soap:Body>
<Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</Body>
</soap:Body>
But I need:
<soap:Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</soap:Body>
So, the question is: how to modify WSDL to have output I need? Any help is greatly appreciated

Related

What is the correct format for SOAP data? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a file, I shared it here http://codepad.org/V6FR2Wbs
It seems this file contains SOAP data. But I do not confirm that this contains SOAP data.
So I want to know, is there any specific format for SOAP data.
I got a similar question here What is the correct format of a SOAP response, but I don't see any format related information there.
There is very simple way to validate if request or response SOAPMessage is valid or not.
As a part of SOAP Message, it includes the namespace that points to SOAP XSD aka. XML schema definition, and the message be valid as per that XSD.
In your example, the SOAP message is--
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"> <SOAP-ENV:Header> <cwmp:ID SOAP-ENV:mustUnderstand="1">279384</cwmp:ID> </SOAP-ENV:Header> <SOAP-ENV:Body> <cwmp:Inform> <DeviceId> <Manufacturer>Huawei Technologies Co., Ltd</Manufacturer> <OUI>00259E</OUI> <ProductClass>EG8040H5</ProductClass> <SerialNumber>48575443FF5E5D9D</SerialNumber> </DeviceId> <Event SOAP-ENC:arrayType="cwmp:EventStruct[1]"> <EventStruct> <EventCode>2 PERIODIC</EventCode> <CommandKey/> </EventStruct> </Event> <MaxEnvelopes>1</MaxEnvelopes> <CurrentTime>2019-06-19T15:30:33+00:00</CurrentTime> <RetryCount>0</RetryCount> <ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[8]"> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name> <Value xsi:type="xsd:string">http://10.240.12.35:7547/1d9564b694ef18090a9377cd6f3217eb</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceSummary</Name> <Value xsi:type="xsd:string">InternetGatewayDevice:1.4[](Baseline:1, EthernetLAN:1, WiFiLAN:2, Time:1, IPPing:1, DeviceAssociation:1)</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name> <Value xsi:type="xsd:string">1.0</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name> <Value xsi:type="xsd:string">172D.A</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name> <Value xsi:type="xsd:string">V5R019C00S115</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name> <Value xsi:type="xsd:string">10.240.12.35</Value> </ParameterValueStruct> </ParameterList> </cwmp:Inform> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
In your example SOAP schema is located as http://schemas.xmlsoap.org/soap/envelope/
And the XSD for that schema is--
<?xml version='1.0' encoding='UTF-8' ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" >
<!-- Envelope, header and body -->
<xs:element name="Envelope" type="tns:Envelope" />
<xs:complexType name="Envelope" >
<xs:sequence>
<xs:element ref="tns:Header" minOccurs="0" />
<xs:element ref="tns:Body" minOccurs="1" />
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:element name="Header" type="tns:Header" />
<xs:complexType name="Header" >
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:element name="Body" type="tns:Body" />
<xs:complexType name="Body" >
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax" >
<xs:annotation>
<xs:documentation>
Prose in the spec does not specify that attributes are allowed on the Body element
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
<!-- Global Attributes. The following attributes are intended to be usable via qualified attribute names on any complex type referencing them. -->
<xs:attribute name="mustUnderstand" >
<xs:simpleType>
<xs:restriction base='xs:boolean'>
<xs:pattern value='0|1' />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="actor" type="xs:anyURI" />
<xs:simpleType name="encodingStyle" >
<xs:annotation>
<xs:documentation>
'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification
</xs:documentation>
</xs:annotation>
<xs:list itemType="xs:anyURI" />
</xs:simpleType>
<xs:attribute name="encodingStyle" type="tns:encodingStyle" />
<xs:attributeGroup name="encodingStyle" >
<xs:attribute ref="tns:encodingStyle" />
</xs:attributeGroup>
<xs:element name="Fault" type="tns:Fault" />
<xs:complexType name="Fault" final="extension" >
<xs:annotation>
<xs:documentation>
Fault reporting structure
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="faultcode" type="xs:QName" />
<xs:element name="faultstring" type="xs:string" />
<xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
<xs:element name="detail" type="tns:detail" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="detail">
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax" />
</xs:complexType>
</xs:schema>
Using any programming language or API or online service, you could validate the SOAP message against the given XSD manually or automated way.
E.g.
As I did using this online service(https://www.liquid-technologies.com/online-xsd-validator) and your SOAP message found valid against the schema.

What changes should i make in my wsdl file to directly consume in SAP ABAP Proxy?

I have created a soap service using jax-ws in java.I want to consume my WSDL in SAP directly using ABAP proxy. How can i make my WSDL compatible for SAP?
I tried including Max and Min occurrence in my WSDL file. It is working when i test with soap ui. But still getting error in SAP like
SOAP Fault Code:3 One or More Soap header block not understood.
I have searched for this error but couldn't find anything useful.
This is WSDL file which is generated from XSD
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://example.com/soap" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://example.com/soap" targetNamespace="http://example.com/soap">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://example.com/soap">
<xs:element name="getOrderRequest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="purchaseOrderNumber" type="xs:long"/>
<xs:element maxOccurs="1" minOccurs="1" name="Type" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="1" name="vCode" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="1" name="vName" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="1" name="Location" type="xs:string"/>
<xs:element name="lineItem" type="tns:lineItem"
maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="lineItem">
<xs:sequence>
<xs:element name="Order_No" type="xs:long"/>
<xs:element name="Material" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="UOM" type="xs:string"/>
<xs:element name="Value" type="xs:decimal"/>
<xs:element name="Tax" type="xs:string"/>
<xs:element name="Item" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
<xs:element name="getOrderResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getOrderRequest">
<wsdl:part element="tns:getOrderRequest" name="getOrderRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getOrderResponse">
<wsdl:part element="tns:getOrderResponse" name="getOrderResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="OrderService">
<wsdl:operation name="getOrder">
<wsdl:input message="tns:getOrderRequest" name="getOrderRequest">
</wsdl:input>
<wsdl:output message="tns:getOrderResponse" name="getOrderResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderServiceSoap11" type="tns:OrderService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getOrder">
<soap:operation soapAction=""/>
<wsdl:input name="getOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderServiceService">
<wsdl:port binding="tns:OrderServiceSoap11" name="OrderServiceSoap11">
<soap:address location="http://localhost:8089/Soap/app/OrderService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I want to know whether my WSDL file is correct?
Your wsdl policy and service elements are missing. You said that you are getting SOAP header understood error. SOAP header generally used for authentication and generally old SAP version not support authentication in header segment. Change your java code and try with basic authentication.

SOAP Payload with nested complexType

I'm trying to make a SOAP request where a parameter is a complex type, and I'm having trouble getting the syntax right.
WSDL: https://www.dayforcehcm.com/DataSvc/DayforceService.svc?singleWsdl
Action: IDayforceService/Query
Here is the SOAP request that was generated by SoapUI:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Body>
<ns1:Query>
<ns1:sessionTicket>?</ns1:sessionTicket>
<ns1:request/>
</ns1:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My question is how to fill in the <ns1:request/> element. The request should be a GetReportDefinitionsRequest, and it needs to provide a string value for XRefCode.
SoapUI isn't being much help here, and WSDL to class generators I've tried have similar problems. At this point I'd settle for just knowing the proper XML syntax
Here are the relevant types (also available in the WSDL above).
Query:
<xs:element name="Query">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="sessionTicket" nillable="true" type="xs:string"/>
<xs:element xmlns:q9="http://Dayforce/Services/Data" minOccurs="0" name="request" nillable="true" type="q9:DFRequest"/>
</xs:sequence>
</xs:complexType>
</xs:element>
GetReportDefinitionsRequest:
<xs:complexType name="GetReportDefinitionsRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFRequest">
<xs:sequence>
<xs:element minOccurs="0" name="XRefCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="GetReportDefinitionsRequest" nillable="true" type="tns:GetReportDefinitionsRequest"/>
DFRequest:
<xs:complexType name="DFRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFObject">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="DFRequest" nillable="true" type="tns:DFRequest"/>
DFObject:
<xs:complexType name="DFObject">
<xs:sequence/>
</xs:complexType>
<xs:element name="DFObject" nillable="true" type="tns:DFObject"/>
I was able to get the sample code running and hook in to get the XML generated for the request. Here's the result, in case it helps anyone in the future.
The important part is to assign the type attribute to the tag. That involves importing the http://www.w3.org/2001/XMLSchema-instance namespace to get the type attribute, and the http://Dayforce/Services/Data namespace for the type itself.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dfs="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<dfs:Query>
<dfs:sessionTicket>?</dfs:sessionTicket>
<dfs:request
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfd="http://Dayforce/Services/Data"
i:type="dfd:GetReportDefinitionsRequest">
<dfd:XRefCode>?</dfd:XRefCode>
</dfs:request>
</dfs:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Referencing ComplexType Elements within ComplexType/Sequence Elements in XSD

I am trying to construct a xsd file (inside a WSDL) to get data from a SOAP Request. I have the expected soap Request:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<m:upsertEntity xmlns:m="http://www.boomi.com/connector/wss">
<eTimeRequest>
<ObjectType>String</ObjectType>
<Action>String</Action>
<eTimeID>String</eTimeID>
<OperativeID>String</OperativeID>
</eTimeRequest>
</m:upsertEntity>
</SOAP-ENV:Body>
Here is what I have tried. You can not have a <xs:ComplexType> within another one. I have tried the referencing approach, but apparently, when I tried to do a SOAP Request with it, it was invalid. What can I do?
Here is the XSD within the WSDL:
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss">
<xs:element name="eTimeRequest" type="eTimeRequest"/>
<xs:complexType name="eTimeRequest">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="0" name="ObjectType" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="Action" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="eTimeID" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="OperativeID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="upsertEntity" type="tns:upsertEntity"/>
<xs:complexType name="upsertEntity">
<xs:sequence>
<xs:element minOccurs="0" type="eTimeRequest"/> <!-- These should be the ObjectType, Action, eTimeID and OperativeID in here -->
</xs:sequence>
</xs:complexType>
</xs:schema>
EDIT
Another thing I noticed in the code I linked was that I used the Type="eTimeRequest" and not ref="eTimeRequest". No matter though, still invalid. Here is the error message I get on validation:
Invalid XML schema: ''eTimeRequest' must refer to an existing element.'
Sorry for those who have read this. I obviously made a mistake in my XSD code, and wasted time doing so.
It's true, <xs:ComplexType> is NOT ALLOWED in <xs:ComplexType>, but <xs:Element> containing <xs:ComplexType> is allowed in <xs:ComplexType>. The original SOAP Request generated was therefore invalid. I ran the new version through our system and it worked.
The Correct XSD Schema in the WSDL should have read:
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss">
<xs:element name="upsertEntity" type="tns:upsertEntity"/>
<xs:complexType name="upsertEntity">
<xs:sequence>
<xs:element name="eTimeRequest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="0" name="ObjectType" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="Action" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="eTimeID" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="0" name="OperativeID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

IPhone-XPath query wont retrieve my node

I'm using GData as my XML parser.
I've tried using an XPath query to retrieve a node -
#"//GetPlacesAutoCompleteResult".
but getNodesForXPath doesn't return any nodes.
so I'm asking, what's wrong with the query I typed in?
P.S
I'm only looking for a way to find out if the node exists or not, I care not about it's child nodes.
here is my .xml file (a result from a soap query to an .ASMX Web-Service).
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPlacesAutoCompleteResponse
xmlns="http://xxxxxxx.com/xxxxxx/webservice">
<GetPlacesAutoCompleteResult>
<xs:schema id="NewDataSet"
xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet"
msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0"
maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="ID"
type="xs:long"
minOccurs="0"/>
<xs:element name="FullName"
type="xs:string"
minOccurs="0"/>
<xs:element name="PlaceTypeID"
type="xs:int"
minOccurs="0"/>
</xs:sequence>
</xs:complexType></xs:element>
</xs:choice>
</xs:complexType></xs:element>
</xs:schema>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<ID>47393</ID>
<FullName>Yifat</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<ID>48497</ID>
<FullName>Haifa</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
<ID>70827</ID>
<FullName
>Haifa - Central Bus Rishon</FullName>
<PlaceTypeID>120</PlaceTypeID>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetPlacesAutoCompleteResult>
</GetPlacesAutoCompleteResponse>
</soap:Body>
</soap:Envelope>
Well with <GetPlacesAutoCompleteResponse xmlns="http://xxxxxxx.com/xxxxxx/webservice"><GetPlacesAutoCompleteResult> you have a default namespace declaration in scope so assuming you use XPath 1.0 you need to bind a prefix to the namespace URI http://xxxxxxx.com/xxxxxx/webservice and use that prefix to qualify element names. For example if the prefix is ws then you would use //ws:GetPlacesAutoCompleteResult.
How you bind a prefix to a namespace URI depends on the XPath API you use, I am not familiar with GData so I can't help you with a code sample.