I have a wsdl with an optional header:
<s:element name="AuthIdentifier" type="tns:AuthIdentifier"/>
<s:complexType name="AuthIdentifier">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="identifier" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
The client is using an integration software (tibco) to connect to my service and claims that the header is required, so he must send it with an empty value:
<Header.AuthIdentifier>
<ns0:AuthIdentifier xmlns:ns0 = "http://www.tal.com/schemas"/>
</Header.AuthIdentifier>
How do I make it optional? So that he won't have to send the whole header at all? Is there a minOccurs or something like that? Or is it already optional as it is now?
According to "Web Service Contract Design & Versioning" Thomas Erl et al (ISBN-13: 978-0-13-613517-3) Chapter 15.4, Defining SOAP Blocks in WSDL:
The WSDL 1.1 Specification is unclear about whether SOAP headers
described in a WSDL document must be included by consumers or not. The
WS-I Basic Profile made it mandatory for consumers to include them,
but WDL 2.0 provides the choice as to whether consumers should be
forced to include them or not. Page 472.
In WSDL 2.0 you can set the attribute wsdl:required="false" in the custom SOAP header block to indicate whether consumers must include this header block.
Related
I am working on implementation of service that should accept SOAP 1.2 request with with HTNG 2.1 header, WS-Addressing (to communicate message IDs between systems and address destinations) and WS-Security (user authentication only).
I have completed the whole business logic of processing payload message and generating proper response but I have a real trouble configuring my service to predefined request.
Here it is:
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<soap2:Header xmlns:soap2="http://www.w3.org/2003/05/soap-envelope"
xmlns:htng="http://htng.org/1.3/Header/"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:wss="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:htnga="http://htng.org/PWSWG/2007/02/AsyncHeaders"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<wsa:Action>http://MyHost/MyService_SubmitRequest</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<htnga:ReplyTo>
<wsa:Address>HTTPS://ResponseHost/Response.SVC</wsa:Address>
</htnga:ReplyTo>
<wss:Security mustUnderstand="1">
<wss:UsernameToken>
<wss:Username>string</wss:Username>
<wss:Password>string</wss:Password>
</wss:UsernameToken>
</wss:Security>
<wsa:MessageID>df559145-78a4-4c85-a264-bf99bbf8df9e</wsa:MessageID>
<htnga:CorrelationID>df559145-78a4-4c85-a264-bf99bbf8df9e</htnga:CorrelationID>
<wsa:To>https://pms.url</wsa:To>
</soap2:Header>
<Body>
<!-- Payload -->
</Body>
</Envelope>
I want configuration in config file, not in code and I have tried all configuration options I could find in various posts without any success.
I am aware that I am probably missing some basics about WCF that I can't spot right now so at least a point in right direction will help.
As far as I know, the MesaageID/ReplyTo header could be added in the SOAP header by setting up the message version.
How to add MessageID in the soap headers of WCF request and response?
And UsernameToken could be added by authenticating the client with username/password pattern.
<customBinding>
<binding name="mybinding">
<textMessageEncoding messageVersion="Soap12WSAddressing10">
</textMessageEncoding>
<security authenticationMode="UserNameOverTransport" includeTimestamp="false" >
</security>
<httpsTransport></httpsTransport>
</binding>
</customBinding>
Result.
Correct way communicate WSSE Usernametoken for SOAP webservice
I don’t know how to add HGNGA:CorrelationID header to the SOAP header, It might relate to the WCF tracing.
Feel free to let me know if there is anything I can help with.
I am working on a ColdFusion SOAP web service and I cannot figure out how to add an annotation child element and documentation child element to the WSDL that is generated.
This is my intended output:
<xsd:element name="country" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>The ISO 3166-1 alpha-2 country code
</xsd:documentation>
</xsd:annotation>
....
</xsd:element>
My ColdFusion generated WSDL looks like this:
<xs:element minOccurs="0" name="country" nillable="true" type="xs:string"/>
I have defined the arguments in the cfcomponent > cffunction like this:
<cfargument name="country" type="string" required="true" default="" hint="The ISO 3166-1 alpha-2 country code"/>
Using the hint attribute does not add the annotation and documentation child elements but I cannot find another way to achieve this in the ColdFusion docs.
In searching for an answer I have seen ColdFusion SOAP web services described as "half-baked". Am I setting myself up for failure by trying this at all?
If you want to control the WSDL that is generated by ColdFusion you can use the wsdlfile attribute of the cfcomponent tag to use a pre-defined WSDL file instead of using the WSDL file generated by ColdFusion.
From the Producing WSDL files page:
For complete control of the WSDL, advanced users can specify the cfcomponent wsdlFile attribute to use a predefined WSDL file.
And from the cfcomponent documentation page:
wsdlfile - Optional - A properly formatted WSDL file to be used instead of WSDL generated by ColdFusion.
Most likely you will need to play around with this a bit to get the output how you want it. I posted this answer to another similar question a while back - https://stackoverflow.com/a/17174756/1636917 Notice the comment that was posted there regarding the endpoint URL needing to be within the WSDL.
I was reading about web services , and was creating wsdl from jax-ws source code, i was able to create the wsdl perfectly , i have a many inputs in a request where i need to set minOccurs and maxOccurs for a specific string input in a request, how can i do this via java code. help me in this
my wsdl piece code
<xs:element name="person"><xs:complexType><xs:sequence>
<xs:element name="employee" type="xs:string" minOccurs="1" maxOccurs="10"/>
<xs:element name="member" type="xs:string"/> </xs:sequence></xs:complexType></xs:element>
You cannot define such limit by jaxb anotations on your classes.
You can have 1, or unbound only as maxoccurency
I am testing a SOAP web service through SoapUI tool. Web Service is deployed on a server and SaopUI project is hitting that web service. My concern is while testing one request if I do not provide a mandatory input parameter even then I am getting successful response. No error at all. On the other hand, if we call the same through web application then error comes.
WSDL request:
<wsdl:message name="update_request">
<wsdl:part name="name" type="xsd:boolean"></wsdl:part>
<wsdl:part name="flag" type="xsd:boolean"></wsdl:part>
</wsdl:message>
Is it possible to call a request with less parameters through SoapUI? Why there is a difference between these two calling methods?
Using the XML view of a Test Request test step in soapUI you can freely edit what shall be sent.
Example:
<soap...>
<MyUpdateRequest>
<name>true</name>
</MyUpdateRequest>
</soap...>
My WebService is deployed on WebLogic 10.3.3.
WSDL/XSD describes input parameter number as mandatory:
<xs:element minOccurs="1" maxOccurs="1" name="number" type="xs:int"/>
MinOccurs="1" means that XML message must contain <number> tag, isn't it?
I expect WebLogic has to validate all requests and server error response should be thrown when request is invalid.
Unfortunatelly, my SOAP client is able to send SOAP request without <number> tag and my webservice implementation receives such an invalid request.
Could you tell me please, is it correct behavior or is it defect in WebLogic?
Should my webservice perform it's own XML validation?
WebLogic does not have XSD Schema Validation enabled by default. You can enable it by adding an annotation to your webservice #SchemaValidation (make sure it com.sun.xml.ws.developer version and NOT the com.sun.xml.ws.internal.developer). However this kind of validation does not work too well if you have a complex XSD Schema (e.g. had problems with GS-1 XSD schemas). I think it has something to do with the xercex parser for xml files that weblogic uses since it can't always find all the elements, however so far I was unable to get to the bottom of it. It works fine for simple schemas.
If you need to validate complex schemas it is better to write your own validator and add it to the WS Message Handler. This is quite a bit of work but you then have full control of it and so far I have found no other solution.
Take a look at my answer here for a similiar situation.
As already pointed, you can use the provided #SchemaValidation annotation that tells WebLogic to validate the message for you.