Why WSDL introduces wsdl:message? And message parts?
What the advantage they could bring over the direct using of the XSD in the operations parameters (input, output, fault)?
How they (wsdl messages with wsdl message parts) can be more abstract then XSD?
Why it is not organized for example that way:
<operation name="GetEndorsingBoarder">
<input type="xsd:string"/>
<output type="xsd:string, xsd:int, xsd:boolean"/>
<fault "type="xsd:string""/>
</operation>
I got it:
Messages not just specify operation's parameters.
Messages and theirs parts are referred in the bindings. It should be possible to bind different parts differently:
<message name="m1">
<part name="body" element="tns:GetCompanyInfo"/>
</message>
<message name="m2">
<part name="body" element="tns:GetCompanyInfoResult"/>
<part name="docs" type="xsd:string"/>
<part name="logo" type="tns:ArrayOfBinary"/>
</message>
<portType name="pt1">
<operation name="GetCompanyInfo">
<input message="m1"/>
<output message="m2"/>
</operation>
</portType>
<binding name="b1" type="tns:pt1">
<operation name="GetCompanyInfo">
<soap:operation soapAction="http://example.com/GetCompanyInfo"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<mime:multipartRelated>
<mime:part>
<soap:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="docs" type="text/html"/>
</mime:part>
<mime:part>
<mime:content part="logo" type="image/gif"/>
<mime:content part="logo" type="image/jpeg"/>
</mime:part>
</mime:multipartRelated>
</output>
</operation>
</binding>
I have missed this since "non SOAP 'literal'" bindings are so uncommon.
A XSD describes the DATA aspects, for example data aspects of webservice call whereas the WSDL describes the purpose of the web services (method calls). You cannot typically figure out the method calls from your data alone.
Check out Cheeso and Marc answers on Generating a WSDL from an XSD file
EDIT: source
The message describes the data being exchanged between the web services' provider and consumer and each web service has two messages:
1) input: parameters of the web service
2) output: return data from the web service
Each message has zero or more part parameters (one for each parameter of the web service's function) Each part parameter associates with a concrete type defined in the types container element.
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
Here, two message elements are defined. The first represents a request message SayHelloRequest, and the second represents a response message SayHelloResponse.
Each of these messages contains a single part element. For the request, the part specifies the function parameters; in this case, we specify a single firstName parameter. For the response, the part specifies the function return values; in this case, we specify a single greeting return value.
Related
My OData v4 client uses generated classes based on the 6.x version of Microsoft.OData.Client.
Now it needs to call an action with the following definition:
<Action Name="Resolve">
<Parameter Name="CertRequestEntity" Type="CertificationRequest" />
<Parameter Name="CertRequestId" Type="Edm.String" Nullable="false" Unicode="false" />
<Parameter Name="RequestSuccess" Type="Edm.Boolean" Nullable="false" />
<Parameter Name="RejectedMessage" Type="Edm.String" Unicode="false" />
</Action>
It is easy to construct primitive parameters with the aid of the BodyOperationParameter class, but I cannot find any documentation on the proper way to construct an entity reference as a parameter. Is this possible? (I ended up using HttpClient with a hand-rolled JSON body.)
Note that the definition above, as written, is invalid; the type of the first parameter should be namespace qualified.
If you have control over the schema, the simplest solution would be to make this a bound action (IsBound="true" on the action definition). Bound actions are similar to extension methods in .NET -- the first (entity) parameter becomes the "binding parameter", and you would call the action by appending the action name (/Resolve) to the URL for the CertificationRequest that you wanted to resolve, passing the remaining (non-binding) parameters in the body.
I have an Apache Camel project that uses CXF to send a SOAP payload . The project has been working flawlessly for over a year.
Recently, I was given a new WSDL to implement for this service ...nothing in the WSDL is suppose to change the payload
I am sending ( same classes and value objects, etc. )...the changes in the WSDL were suppose to be totally unrelated to
the payload I am sending.
I used wsdl2java, in my Maven POM, to generate the java sources from the WSDL ( as I did before ) and all compiles just fine & service deploys fine ( JBoss Fuse ).
When I send the payload however, the service complains that there is an "unexpected element" ...this is
strange since I did not change the payload and the Soap "Operation Name" I am calling is the same as with the old
WSDL ...the new WSDL has a different "serviceClass" name, however, the method I need to invoke is the same.
In the log output, I see the soapAction is not set but I am not sure this should matter ...once again, the
code ran fine with the previous WSDL which essentially has the same serviceClass elements.
As can be seen in the code fragment, I am attempting to use the createEDIInvoices operation from the WSDL ...that
operation expects a createEDIInvoices object ( which I am definately passing ) ...the log though shows
that the SOAP server was expecting createEDIInvoicesResponse :
Unexpected element {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices found.
Expected {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoicesResponse.
Anyhow, opinions regarding the issue are welcome... I'm kinda wondering if I am not doing enough to specify the proper SOAP operation to execute
Here is the relevant code fragment from my Camel route ...note that the code blows on the to("cxf:...") call ...the bean is never called
from("direct:inspyrus-processing")
// specify SOAP operation as defined in WSDL
.setHeader(CxfConstants.OPERATION_NAME,
constant("createEDIInvoices"))
.setHeader(Inspyrus_Auth_Header, simple("{{inspyrus.auth.header}}"))
.to("cxf:http://fergusonsbx.invoice-automation.com/ExternalInspyrusService/ExternalInspyrusService" +
"?serviceClass=com.inspyrus.generated.invoiceprocessingservice.ExternalInspyrusService" +
"&wsdlURL=wsdl/Inspyrus_030119.wsdl" + "&cxfEndpointConfigurer=#cxfConfigurer" + "&loggingFeatureEnabled=true")
.to("bean:parse-inspyrusresponse")
.removeHeader(Inspyrus_Auth_Header)
.log(LoggingLevel.DEBUG, Constants.APP_ID + ": Inspyrus Processing Complete");
The CXFConfigurer code is below:
ManagedBean
#Named("cxfConfigurer")
public class CxfConfigurer implements CxfEndpointConfigurer {
private static final long CXF_CONNECTION_TIMEOUT = 180000;
private static final long CXF_RECEIVE_TIMEOUT = 360000;
#Override
public void configure(final AbstractWSDLBasedEndpointFactory factoryBean) {
}
#Override
public void configureClient(final Client client) {
final HTTPConduit http = (HTTPConduit) client.getConduit();
final HTTPClientPolicy policy = http.getClient();
policy.setAutoRedirect(true);
policy.setConnection(ConnectionType.KEEP_ALIVE);
policy.setConnectionTimeout(CXF_CONNECTION_TIMEOUT); // default is 30K
policy.setReceiveTimeout(CXF_RECEIVE_TIMEOUT); // default is 60K
// Don't be too strict with CN checking
final TLSClientParameters tlsCP = new TLSClientParameters();
tlsCP.setDisableCNCheck(true);
http.setTlsClientParameters(tlsCP);
}
#Override
public void configureServer(final Server server) {
}
The WSDL was generated from http://fergusonsbx.invoice-automation.com/ExternalInspyrusService/ExternalInspyrusService?wsdl ...it is below
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. --><definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://xmlns.inspyrus.com/ExternalInspyrusService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://xmlns.inspyrus.com/ExternalInspyrusService" name="ExternalInspyrusService">
<types>
<xsd:schema>
<xsd:import namespace="http://xmlns.inspyrus.com/ExternalInspyrusService" schemaLocation="ExternalInspyrusService_1.xsd"/>
</xsd:schema>
</types>
<message name="createEDIInvoices">
<part name="parameters" element="tns:createEDIInvoices"/>
</message>
<message name="createEDIInvoicesResponse">
<part name="parameters" element="tns:createEDIInvoicesResponse"/>
</message>
<portType name="ExternalInspyrusService">
<operation name="createEDIInvoices">
<input message="tns:createEDIInvoices"/>
<output message="tns:createEDIInvoicesResponse"/>
</operation>
</portType>
<binding name="ExternalInspyrusServicePortBinding" type="tns:ExternalInspyrusService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="createEDIInvoices">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ExternalInspyrusService">
<port name="ExternalInspyrusServicePort" binding="tns:ExternalInspyrusServicePortBinding">
<soap:address location="http://fergusonsbx.invoice-automation.com:80/ExternalInspyrusService/ExternalInspyrusService"/>
</port>
</service>
</definitions>
Relevant Log Fragments
ID: 1
Address: http://fergusonsbx.invoice-automation.com/ExternalInspyrusService/ExternalInspyrusService
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], accountId=[SANAN], Authorization=[n5zMltp5l2z2L+2tDC9l], breadcrumbId=[ID-fuse-localdomain-43307-1551479341458-13-1], Connection=[Keep-Alive], DESTINATION_SELL_LOCATION=[454], EDI_810_PONUMBER=[L454-11593], ISFREIGHT=[false], MAIN_BRANCH_NUMBER=[0061], PO_TYPE=[DIRECT], PROCESSED=[true], **SOAPAction=[""]**, SOURCE_PARTY_ID=[22449], UNPROCESSED_VENDORID=[SANAN*10770~1~1], UNPROCESSED_VENDORNUMBER=[10770], WAREHOUSE_NUMBER=[454]}
**Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:createEDIInvoices xmlns:ns2="http://xmlns.inspyrus.com/ExternalInspyrusService"><entityID>23 ....
16:47:18,662 INFO [org.apache.cxf.services.ExternalInspyrusService.ExternalInspyrusServicePort.ExternalInspyrusService] (default-workqueue-1) Inbound Message**
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Date=[Sat, 02 Mar 2019 16:51:54 GMT], transfer-encoding=[chunked]}
Payload: <?xml version='1.0' encoding='UTF-8'?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header/><soap:Body><ns2:createEDIInvoices xmlns:ns2="http://xmlns.inspyrus.com/ExternalInspyrusService"><entityID>23</entityID><invoiceImport><header><captureProfile>EDI</captureProfile><currencyCode>USD</currencyCode><documentType>Invoice</documentType><flexAttribute10>Batch # 543421</flexAttribute10><flexAttribute12>543421</flexAttribute12><flexAttribute17>347.46</flexAttribute17><flexAttribute19>ST005.txt</flexAttribute19><flexAttribute21>120.46</flexAttribute21><flexAttribute22>16B286664984</flexAttribute22><flexAttribute23>EXLA ESTES EXPRESS LINES</flexAttribute23><flexAttribute24>W196-12965 </flexAttribute24><flexAttribute26>1% DISC 30 Days</flexAttribute26><flexAttribute27>2.22</flexAttribute27><flexAttribute28>February 17, 2019</flexAttribute28><flexAttribute29>February 16, 2019</flexAttribute29><flexAttribute3>125.00</flexAttribute3><flexAttribute30>1.00%</flexAttribute30><flexAttribute5>0454</flexAttribute5><flexAttribute6>DIRECT</flexAttribute6><flexAttribute8>SANAN*22449*383148735</flexAttribute8><invoiceDate>2019-01-17</invoiceDate><invoiceNumber>383148735</invoiceNumber><invoiceStatus>Open</invoiceStatus><invoiceTotalAmount>347.46</invoiceTotalAmount><leAddress1>PO BOX 9406</leAddress1><leCity>HAMPTON</leCity><leName>FERGUSON - HAMPTON</leName><lePostalCode>23670</lePostalCode><leState>VA</leState><orgID>0061</orgID><PONumber>L454-11593</PONumber><region>NA</region><scanDate>2019-01-17</scanDate><shipToAddress1>5206 W WATERS AVENUE</shipToAddress1><shipToCity>TAMPA</shipToCity><shipToName>FERGUSON 0196 TAMPA</shipToName><shipToPostalCode>33634</shipToPostalCode><shipToState>FL</shipToState><vendorAddress1>P.O Box 202893</vendorAddress1><vendorCity>DALLAS</vendorCity><vendorID>SANAN*22449~1~1</vendorID><vendorName>AS America, Inc.</vendorName><vendorNumber>22449</vendorNumber><vendorPostalCode>75320</vendorPostalCode><vendorSiteID>SANAN*22449~1~1</vendorSiteID><vendorState>TX</vendorState></header><lineItems><lineItem><lineNumber>1</lineNumber><lineType>ITEM</lineType><description># 5 FT AFR BATH LH OUT SOLAR WH</description><quantity>1</quantity><unitPrice>227.0000</unitPrice><lineTotalAmount>227.00</lineTotalAmount><UOM>EA</UOM><attribute4>0263212.020</attribute4><attribute5>A0263212020</attribute5></lineItem><lineItem><lineNumber>2</lineNumber><lineType>ITEM</lineType><description>Warranty</description><quantity>1</quantity><unitPrice>-4.5400</unitPrice><lineTotalAmount>-4.54</lineTotalAmount></lineItem></lineItems></invoiceImport></ns2:createEDIInvoices><soap:Fault><faultcode>F</faultcode><faultstring>Authorization Token not Found</faultstring></soap:Fault></soap:Body></soap:Envelope>
--------------------------------------
16:47:18,663 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default-workqueue-1) Interceptor for {http://xmlns.inspyrus.com/ExternalInspyrusService}ExternalInspyrusService#{http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices has thrown exception,
unwinding now: org.apache.cxf.interceptor.Fault:
Unexpected element {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoices found.
Expected {http://xmlns.inspyrus.com/ExternalInspyrusService}createEDIInvoicesResponse.
The following is an implementation of the specification outlined in the above picture.
#WebService
#SOAPBinding(style = Style.DOCUMENT)
public interface WithdrawService {
#WebMethod
public Response withdraw(
#WebParam(name="CORPCODE") String corpcode,
#WebParam(name="SERVCODE") String servcode,
#WebParam(name="AMOUNT") double amount,
#WebParam(name="CCYID") String ccyid,
#WebParam(name="ACCTNO") String acctno,
#WebParam(name="REFVAL1") String refvel1,
#WebParam(name="REFVAL2") String refval2,
#WebParam(name="TRANREF") String tranref,
#WebParam(name="DESC") String desc,
#WebParam(name="LICENSEID") String licenseid,
#WebParam(name="LICENSEKEY") String licensekey
);
}
The following WSDL is generated when a user accesses the ?wsdl link.
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b.
-->
<!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b.
-->
<definitions targetNamespace="http://withdraw.kbz.nirvasoft.com/" name="WithdrawServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://withdraw.kbz.nirvasoft.com/" schemaLocation="http://localhost:8080/WithdrawService/withdraw?xsd=1"/>
</xsd:schema>
</types>
<message name="withdraw">
<part name="parameters" element="tns:withdraw"/>
</message>
<message name="withdrawResponse">
<part name="parameters" element="tns:withdrawResponse"/>
</message>
<portType name="WithdrawService">
<operation name="withdraw">
<input wsam:Action="http://withdraw.kbz.nirvasoft.com/WithdrawService/withdrawRequest" message="tns:withdraw"/>
<output wsam:Action="http://withdraw.kbz.nirvasoft.com/WithdrawService/withdrawResponse" message="tns:withdrawResponse"/>
</operation>
</portType>
<binding name="WithdrawServiceImplPortBinding" type="tns:WithdrawService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="withdraw">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="WithdrawServiceImplService">
<port name="WithdrawServiceImplPort" binding="tns:WithdrawServiceImplPortBinding">
<soap:address location="http://localhost:8080/WithdrawService/withdraw"/>
</port>
</service>
</definitions>
We are unhappy with two things.
We do not get any xsd documents for the types used.
We cannot say whether fields are required in the generated wsdl.
I would like to know how we could achieve them using our code.
You can get your XSD from
http://localhost:8080/WithdrawService/withdraw?xsd=1
Depending on the server you use you can ask JAX-WS to generate embedded XSD file. Alternatively you can ask JAX-WS to use you own WSDL.
I would like to iterate through an array and use the value taken from the array to put it within an http inbound endpoint. How would I be able to iterate through this array and take the value from the array to place it as a variable within the http inbound endpoint?
The code that I used to try was:
<flow name="foreachFlow1" doc:name="foreachFlow1">
<poll frequency="2000">
<foreach collection="#[groovy:['localhost:8082', 'localhost:8083']]"
doc:name="For Each">
<http:outbound-endpoint exchange-pattern="request-response"
address="http://#[payload]" method="GET" doc:name="HTTP" />
</foreach>
</poll>
</flow>
and I get the error
Invalid content was found starting with element 'poll'
Inbound endpoints are message sources and can not be parametrized the way you're describing.
To achieve your goal, trying a <poll> message source to wrap a foreach that uses http:outbound-endpoint to perform GET (#method) request-response (#exchange-apttern) interactions.
The trick is to bring the results for the HTTP calls back through the foreach, which by default do not do it. The following illustrate a potential approach:
<flow name="foreachFlow1">
<poll frequency="2000">
<processor-chain>
<set-variable variableName="httpResponses" value="#[[]]" />
<foreach collection="#[groovy:['localhost:8082', 'localhost:8083']]">
<http:outbound-endpoint
exchange-pattern="request-response" address="http://#[payload]"
method="GET" />
<expression-component>httpResponses.add(message.payloadAs(java.lang.String))
</expression-component>
</foreach>
</processor-chain>
</poll>
<logger level="INFO" message="#[httpResponses]" />
</flow>
<!-- Test server stubs -->
<flow name="server8082">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8082" />
<set-payload value="This is 8082" />
</flow>
<flow name="server8083">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8083" />
<set-payload value="This is 8083" />
</flow>
This is what I have in my schema section of my WSDL to specify the field has to be comparison operators
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="<|>|<=|>=|="/>
</xsd:restriction>
</xsd:simpleType>
SoapUI complains about this part of the WSDL, I tried to set the value to something with non special characters and the WSDL is valid. So I tried to replace that whole long string to be
value=">gt;" and it valid but value="<lt;" is not valid, and value=">" is also not valid. My question is, why does the WSDL validation need > to be double escaped?
The main question is, how to provide a valid less than side within the pattern value.
This might actually be a bug in SoapUI. I tried using the following schema and XML with Apache Xalan (in Java):
Schema:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.foo.com/"
xmlns:tns="http://www.foo.com/"
elementFormDefault="qualified">
<element name="foo">
<simpleType>
<restriction base="string">
<pattern value="<|>|<=|>=|="/>
</restriction>
</simpleType>
</element>
</schema>
Sample XML:
<foo xmlns='http://www.foo.com/'>></foo>
and it validates fine. When I try this instead:
<foo xmlns='http://www.foo.com/'>abc</foo>
I get the following error, as expected: cvc-pattern-valid: Value 'abc' is not facet-valid with respect to pattern '<|>|<=|>=|=' for type '#AnonType_foo'.
My recommendation is to try using an enum instead. For example:
<simpleType>
<restriction base="string">
<enumeration value="<" />
<enumeration value=">" />
<enumeration value="<=" />
<enumeration value=">=" />
<enumeration value="=" />
</restriction>
</simpleType>
And see if SoapUI likes this better. Hope this helps!
I think I solved my own problem, why would you define in your schema that one of the allowable value is
<xsd:restriction base="xsd:string">
<xsd:pattern value="=|>|>=|<|<=|<>|[Ii][Nn]|[Nn][Oo][Tt] [Ii][Nn]|[Ll][Ii][Kk][Ee]"/>
</xsd:restriction>