Hello I'm developping some web services in java, so I have created a wsdl file to describe this services.
With my wsdl I create the web services (servcer side). but I can't create the client side because
I think the problem is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://tempuri.org/Services/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<bil:ArrayOfElement soapenc:arrayType="?" soapenc:offset="?" id="?" href="?">
<!--1 or more repetitions:-->
<Element>
<code>?</code>
<codeElement>?</codeElement>
<TypeService>?</TypeService>
</Element>
</bil:ArrayOfElement>
</soapenv:Body>
</soapenv:Envelope>
In fact, I don't know what we must put in this line:
<bil:ArrayOfElement soapenc:arrayType="?" soapenc:offset="?" id="?" href="?">
And for my tests I send this enveloppe and it works (but like you see it's another wsdl):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://tempuri.org/Services/">
<soapenv:Header/>
<soapenv:Body>
<bil:ArrayOfElement>
<Element>
<code>exmepleCode</code>
<codeElement>exmempleCodeElement</codeElement>
<TypeService>a_Service_Type</TypeService>
</Element>
</bil:ArrayOfElement>
<!-- other elements-->
</soapenv:Body>
</soapenv:Envelope>
How did you create the WSDL?
one important issue when working with web services, or xml schemas (xsd) in general, is that there's no simple one to one mapping between xsd and language specific types (java in this case).
one of the implication is when doing a 'round trip' mapping (java to xsd, and then xsd to java) you don't get always what you started with - especially when using non simple types such as arrays or other containers.
The solution in this case is to create a "correct" xsd schema, and derive the javadefinitions for the client and the server from this schema - only a single xsd to java transformation is done, so no issues of rount trip mapping are encountered.
To create such a xsd, you should use the native methods of defining collections in xsd, which is basically adding minOccurs and maxOccurs attributes to the basic element.
you can find more detailed reference here
Note that you don't have to use hand crafted xsd - you can also use any xsd editor (most modern IDE's have one) to get the same results.
Related
I am using SOAP ui to Test WCF services.
I want to pass value for input parameters (ExternalReference) dynamically from properties(Key-Value) available in SOAP UI tool.
Can any one know how to do ?
Sample XML
<soapenv:Body>
<mer:GetDocumentSetList>
<!--Optional:-->
<mer:DocumentSetListIn>
<mer1:SearchCriteria>
<!--Optional:-->
<mer1:ExternalReference>8B7A2F87-3546-456D-93EF-C8515BF4A14A</mer1:ExternalReference>
<mer1:ListDateFrom>2020-02-24</mer1:ListDateFrom>
<!--Optional:-->
<mer1:ListDateTo>2020-02-25</mer1:ListDateTo>
</mer1:SearchCriteria>
</mer:DocumentSetListIn>
</mer:GetDocumentSetList>
It's very easy. in the Request XML you specify it like this:
<ns1:SomeParameter>${#Project#MyPropName}</ns1:SomeParameter>
Assuming that MyPropName is a Project-level property. If you want to use a test case level property, use
${#TestCase#MyPropName}
I'm trying to map a message from the following format via xslt:
<soapenv:Envelope xmlns:soapenv="..." ns...>
<soapenv:Header>
<ns:myHeader>
<ns1:myData>VALUE_I_WANT</ns1:myData>
</ns:myHeader>
</soapenv:Header>
<soapenv:Body>
<ns2:otherData>
...
</ns2:otherData>
</soapenv:Body>
</soapenv:Envelope>
Currently my mapping handles all of the fields in the soapenv:Body tag, but for one of my mapped nodes I need the value in soapenv:Header > ns:myHeader > ns1:myData.
Is it possible to get a value from the soap header in XSLT and what kind of xpath would I need to achieve this?
Assuming you use the WCF-BasicHttp adapter, you could use xslt like you wanted, but only if you specified Envelope -- entire <soap:Envelope> as data selection for the SOAP Body element. If you don't specify it, your header will be removed from the message body and xpath statements on the header will be impossible.
Your other option is getting the value from the context property InboundHeaders with namespace http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties. The adapter puts the SOAP header values into that InboundHeaders context property by default. If you need the context value in a mapping, without an orchestration, try looking into the community made Context Accessor Functoid.
Doing your own property promotion on header values, like you asked for in the comments, is also possible, but not in xslt. Only if you add an XML Disassembler Pipeline Component, then make a schema of the entire soap message, then set promotions on the schema and finally; specify the schema in the Document schemas part of the Pipeline Component. I wouldn't suggest using this approach, as it requires you to deploy a soap schema which will be duplicate with the default BizTalk soap schema.
I've inherited a project that communicates with a SOAP-based web service. I'm a total noob at this, although have been doing Java for many years and have done a good bit with XML.
We have a WSDL file for the service, which contains the schema at the top and all the message definition stuff below. At the core of the problem, when I try to connect to the service through our code, I get the dreaded unable to marshal type "https.api_blah_com.services.v4.Product" as an element because it is missing an #XmlRootElement annotation]
My project already has a jaxws binding file:
<jaxws:bindings wsdlLocation="../resources/wsdl/BlahAPI.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[#targetNamespace='https:api.blah.com/services/v4']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xjc:generateElementProperty>true</xjc:generateElementProperty>
</jxb:globalBindings>`
</jaxws:bindings>
</jaxws:bindings>
Now I've read that in order to get all my Java classes generated with #XmlRootElement, I need to add a jaxb:globalBinding turning on simple mode.
I've tried adding to my local copy of the WSDL this:
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
But the JAXB compiler complains that it cannot honor this globalBindings customization because it's attached to a wrong place or is inconsistent with other bindings.
So I tried adding another bindings file, just for jaxb, like so:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="../resources/wsdl/blah.wsdl">
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
But then I get an error that blah.wsdl is not part of this compilation.
I am so close to calling this service...I just cannot get past this one thing, and it's all new to me so I'm not sure what else to try.
I could split out their WSDL into an XSD and a WSDL? Is that required to make this work?
I think you have to bind the xsd file not wsdl at this location. <jaxb:bindings schemaLocation="../resources/wsdl/blah.wsdl">. Please refer to section "External Binding Customization Files" at link.
Not sure if JAXB Binding is configured correctly. The #XmlRootElement required if class forms the root of your element structure. However in SOAP, SOAP element would form root of the XML, Hence check if your ObjectFacory.java class is generated, if generated verify if a method is created for the class type which returns an instance of the class type for example you have class Foo an method `public Foo createFoo() which returns instance of Foo should be present in your ObjectFoacory.java
However I would suggest you to use CXF provided WSDL2java this with client option enabled. It takes few minutes to configure a client code
I have a SOAP response from a TestStep in SoapUI. I want to parse each value of a specific element in the response and send it as a parameter to a separate request call to another web service.
<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>
<searchResponse xmlns="urn:messages_2012_2.platform.webservices.technoplat.com">
<platformCore:searchResult xmlns:platformCore="urn:core_2012_2.platform.webservices.technoplat.com">
<platformCore:searchRowList>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
<tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">
<platformCommon:tranId>
<platformCore:searchValue>17678</platformCore:searchValue>
</platformCommon:tranId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
<tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">
<platformCommon:tranId>
<platformCore:searchValue>17705</platformCore:searchValue>
</platformCommon:tranId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2012_2.transactions.webservices.technoplat.com">
<tranSales:basic xmlns:platformCommon="urn:common_2012_2.platform.webservices.technoplat.com">
<platformCommon:tranId>
<platformCore:searchValue>17777</platformCore:searchValue>
</platformCommon:tranId>
</tranSales:basic>
</platformCore:searchRow>
</platformCore:searchRowList>
</platformCore:searchResult>
</searchResponse>
</soapenv:Body>
In the SOAP response above, I want to capture the values: 17678, 17705 and 17777 separately and send them as a parameter to another SOAP Request TestStep. Most people recommend using a groovy script for the recursion.
My questions are:
1. whats the best way to perform extraction of values from the SOAP response above and iterate and make a separate SOAPRequest TestStep in SoapUI?
2. Assuming each value is extracted in a Groovy TestStep, how can I feed those out to a "results.txt" kind of csv (name value pair) file outside.
Any suggestions would be appreciated.
This is the way I used before may be not the best.
parsing XML by XmlSluper.
There are many ways to process XML (see: http://groovy.codehaus.org/Processing+XML)
use XmlParser and CSVWriter (opencsv) to convert XML to CSV
I'd seen good example from here: http://blog.ktronline.com/2011/12/creating-csv-file-from-xml-using-groovy.html
if you're using soapUI Pro the easiest way to do this is use the DataSource TestStep with a XML DataSource (see http://blog.smartbear.com/software-quality/bid/170520/How-to-Use-XML-DataSources-for-Response-Processing-in-soapUI for an example). If you're using the free version then scripting is your best option!
Good Luck!
/Ole
I have deployed my webservice into Tomcat.
The WSDL has got some operations like ViewOptions, but when I ran that, I got this error:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>1</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Why do we get this error?
The message isn't an "error" but rather a warning n need not be solved but ignored. An XML document is a data structure but does not contain any presentation/style information internally. Normally an XML document is used in inter-application communication or as a pure data structure that is then used with additional presentation/style information to display to users.
XML can be applied style by XSLT just as HTML by CSS and the above warning can be eradicated An eg: of applying xls to xml
We don't present xml using xls for RSS, Web Services as they are just used for communication without applying stylesheet rather than meant to be presented to user in browser.
So, everything is fine here.
what worked for my case. I replaced all the links of ... with window.open("...link", "_self") and changed
import {
HashRouter as Router,
} from 'react-router-dom';