Again I am back with a question related to the same wsdl, this time wanted to remove all namespaces in the request, and conforming to the wsdl.
The same wsdl tripservice wsdl from the link ,simply replace the "from" element with the below.
<xs:element minOccurs="0" name="from" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Using soapui we know that the below request xml conforms to wsdl.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trip="http://trip.price.service" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<trip:getTripPrice>
<trip>
<adults>9</adults>
<duration>9</duration>
<from xsi:nil="true" />
<rooms>3</rooms>
</trip>
</trip:getTripPrice>
</soapenv:Body>
</soapenv:Envelope>
I removed almost all namespaces from the request, however not able to remove xsi namespace from the request, so as to conform to wsdl
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header/>
<Body>
<getTripPrice xmlns="http://trip.price.service">
<trip xmlns="">
<adults>9</adults>
<duration>9</duration>
<from xsi:nil="true" />
<rooms>3</rooms>
</trip>
</getTripPrice>
</Body>
</Envelope>
How to remove xsi namespace as well, still valid as per the wsdl?
This is a generic XML processing question, "How do you control the use and production of namespace prefixes in XML producer 'x'"? In your case, according to the comments, 'xml producer X is xslt.' It will then depend on what implementation of XSLT you are using and whether it has any options to control this particular behavior.
In general, xslt takes the usual attitude that namespace prefixes are just syntactic sugar, and does not offer convenient mechanisms for controlling their use. You may be able to encourage it make more use of prefixes by declaring them at the top of your XSLT definition.
I recommend compression as the real solution to reducing bandwidth usage.
Related
I'm consuming a SOAP Web Service that requires the text ":com" in some of the tags. For example instead of
<soapenv:Envelope >
<soapenv:Body>
<RunSimpleTrip>
<c>
<CompanyCode>CompanyCode</CompanyCode>
<Password>Password</Password>
<Username>Username</Username>
</c>
<BasicTrip>
<Comments />
<Driver>Some Driver</Driver>
<EndOdometer />
...
</BasicTrip>
</RunSimpleTrip>
</soapenv:Body>
</soapenv:Envelope>
It needs to be
<soapenv:Envelope >
<soapenv:Body>
<RunSimpleTrip>
<c>
<com:CompanyCode>CompanyCode</com:CompanyCode>
<com:Password>Password</com:Password>
<com:Username>Username</com:Username>
</c>
<BasicTrip>
<com:Comments />
<com:Driver>Some Driver</com:Driver>
<com:EndOdometer />
...
</BasicTrip>
</RunSimpleTrip>
</soapenv:Body>
</soapenv:Envelope>
Notice how not all the tags need the prefix (like the c or BasicTrip tags). Just the inner ones, the fields of the objects.
Am I stuck with doing a StringReplace on each individual tag, or is there an option I'm missing? Is there some way to toggle the importer or WSDL .pas file to do this by itself?
This is the same question, which received no good answer at the time Delphi HttpRio SOAPHTTPClient does not add a prefix to namespaced variables . And just like the question, when I generate this via soapUI it places the ":com" on the needed tags.
Edit: Here's a snippet of the WSDL that describes a BasicTrip
<xs:complexType name="BaseTrip">
<xs:sequence>
<xs:element name="Comments" nillable="true" type="xs:string"/>
<xs:element name="Driver" nillable="true" type="xs:string"/>
<xs:element name="EndOdometer" type="xs:decimal"/>
<xs:element name="GetMapPoints" type="xs:boolean"/>
...
</xs:sequence>
</xs:complexType>
My goal is to add #Entity annotations to the classes that are generated from a wsdl. I'm using cxf-codegen-plugin's wsdl2java goal, and pointing at a local wsdl file. I can generate all the sources without any problem, but when I try to add a binding file, I'm running into problems.
Here's a segment of the wsdl (the file is CAAudit.wsdl and is in my resources directory):
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audw="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audx="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:qikrsp="urn:us:gov:hhs:acf:qikrsp"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="CAAudit"
>
<wsdl:types>
<xsd:schema targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xsd:import namespace="urn:us:gov:hhs:acf:qikrsp"
schemaLocation="QuickResponse.xsd" />
<xsd:complexType name="NotifyCAAuditRequest" >
<xsd:sequence>
<xsd:element ref="qikrsp:QuickResponse" />
</xsd:sequence>
</xsd:complexType>
....
My first question is I'm really not certain what should go in the binding file. First, I'm pretty sure that I need jaxws bindings to work with the wsdl (the jaxb binding only has the schemaLocation attribute), although I don't need to generate web service classes.
Next, I'm not sure I'm not sure if the introduction of a new xmlns in the schema element will cause problems for an xpath search. I did have problems running it with notepad++'s xpath evaluation.
Also, I'm not sure if the fact that the QuickResponse element (which is the class I want to annotate) is defined by a reference is hindering my efforts. I'm not sure if or how (or where) I would include the referenced xsd file.
Here is one possible binding file (I was just trying to get an #Generated on the class to start with):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="2.1"
>
<jaxws:bindings wsdlLocation="CAAudit.wsdl"
node="/wsdl:definitions/wsdl:types">
<jaxb:bindings node=".//xsd:schema">
<annox:annotate>#javax.annotation.Generated({"JAXWS"})</annox:annotate>
</jaxb:bindings>
</jaxws:bindings>
</jaxb:bindings>
I did not manage to customize schema embedded in WSDL. This are my latest efforts:
https://github.com/highsource/jaxb2-annotate-plugin/blob/master/tests/jaxws/src/main/resources/wsdl-bindings.xjb
What works with WSDLs is attaching customizations via SCD. But SCD does not allow proprietary customization elements (like annotate:*). So that won't help with jaxb2-annotate-plugin.
So the only thing which would probably work is to extract schema from the WSDL into an own file.
I have made a page that is suppose to be a common exit point (success page) for all Orbeon applications made both manually creating XFroms and by Orbeon Builder. The page is really simple as it is only supposed to show a generic message that is specified in a form that gets redirected to the page after submission. This feels like a trivial task, yet I have struggled a lot with it.
The documentation says:
The "POST" solution
If your XForms page responds to an HTTP POST containing XML, then it can access the content of the POST data with a special URL called input:instance:
<xforms:instance id="user-data" src="input:instance"/>
This results in the user-data instance being populated with the XML data posted to the XForms page. It's as easy as this!
NOTE: Nothing prevents you to combine this method with getting data from the request or a service.
My page-flow.xml
<config xmlns="http://www.orbeon.com/oxf/controller"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<page id="main" path-info="/thankyou/" view="thankyou.xhtml"/>
<page id="test" path-info="/thankyou/test" view="test.xhtml">
<action when="/form/fromPage = 'test'">
<result page="main"/>
</action>
</page>
<epilogue url="oxf:/config/epilogue.xpl"/>
</config>
thankyou.xhtml
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xhtml:head>
<xhtml:title>Thank you</xhtml:title>
<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms">
<xforms:instance id="form-instance" src="input:instance"/>
<xforms:bind id="form-binds" nodeset="instance('form-instance')">
<xforms:bind id="success-bind" ref="/form/success/successPageText"/>
</xforms:bind>
</xforms:model>
</xhtml:head>
<xhtml:body>
<xhtml:p>
<xhtml:output ref="instance('form-instance')/form/success/successPageText"/>
</xhtml:p>
<xhtml:p>
<xhtml:output bind="success-bind"/>
</xhtml:p>
<xhtml:p>
<xhtml:a href="http://www.google.com">Away from here</xhtml:a>
</xhtml:p>
</xhtml:body>
</xhtml:html>
test.xhtml
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xhtml:head>
<xhtml:title>Thankyou page test</xhtml:title>
<xforms:model id="form-model">
<xforms:instance id="form-instance">
<form>
<input>text here</input>
<fromPage>test</fromPage>
<success>
<successPageText>
This is a test.
</successPageText>
</success>
</form>
</xforms:instance>
<xforms:bind id="form-binds" nodeset="instance('form-instance')">
<xforms:bind id="input-bind" ref="/form/input" type="xs:string" required="true()"/>
</xforms:bind>
<xforms:submission id="main-submission" method="post" action="/thankyou/test"
ref="instance('form-instance')" validate="false" replace="all"/>
</xforms:model>
</xhtml:head>
<xhtml:body>
<xhtml:table>
<xhtml:tr>
<xhtml:td>
<xforms:input bind="input-bind" id="input-control">
<xforms:label>Type something here </xforms:label>
</xforms:input>
</xhtml:td>
</xhtml:tr>
<xhtml:tr>
<xhtml:td>
<xforms:submit submission="main-submission" id="submit-control">
<xforms:label>Test</xforms:label>
<xforms:setvalue ev:event="DOMActivate">submit</xforms:setvalue>
</xforms:submit>
</xhtml:td>
</xhtml:tr>
</xhtml:table>
</xhtml:body>
</xhtml:html>
The thankyou page gets loaded when submitting from the test page, but the value set for the 'successPageText' is not shown.
I have tested with a Java servlet that when submitting from other pages/forms the xml data is included with the post, but I am unable to figure how to use it on the thankyou page.
The main reason your example doesn't work is that in test.xhtml you are posting to yourself. Instead, you should post to the target page. So write the submission as:
<xforms:submission id="main-submission" method="post"
action="/20110920-so-thankyou/"
ref="instance('form-instance')" validate="false" replace="all"/>
The pattern of posting to yourself, and then determining in page-flow.xml what the next page should be, is considered to be deprecated. It still works, there are still situations where it makes sense, but in the majority of the cases, the cost of the added complexity is higher than the benefits you get from this decoupling.
Finally, a couple of things very specific to your example:
In thankyou.xhtml, you were using <xhtml:output>, which you'll want to change to <xforms:output>.
The XPath expression in the first output should be instance('form-instance')/success/successPageText without form. Remember: instance() returns the root element, not the document element.
I am working on a project that uses the contract first approach. I was given a WSDL and three xsd's. When I use svcutil it generates a wrapper around the response class like so:
public partial class getDataByIdResponse1 {
public getDataByIdResponse getDataByIdResponse;
public getDataByIdResponse1() {
}
public getDataByIdResponse1(getDataByIdResponse getDataByIdResponse) {
this.getDataByIdResponse = getDataByIdResponse;
}
}
The getDataByIdResponse is wrapped inside a getDataByIdResponse1 object. This is done by svcutil and I have no idea why. The getDataByIdResponse1 object does not exist in the WSDL:
<wsdl:message name="getDataById">
<wsdl:part name="response" element="tns:getDataByIdResponse"/>
</wsdl:message>
<xs:element name="getDataByIdResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="sbc:DataType" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
Why is the type getDataByIdResponse wrapped in getDataByIdResponse1? Is there a switch for svcutil I should have used?
I'm in the same boat as you but I don't just want to live with it. I want to generate clean (unwrapped) contracts. If the wsdl and xsd's were given to you then there are some rules that your schema and wsdl need to follow in order for svc util to generate unwrapped code. These links helped me understand the issue a little better
http://pzf.fremantle.org/2007/05/handlign.html
http://mharbauer.wordpress.com/2007/10/19/wcf-datacontract-serializer-and-documentwrapped/
For now my schema and wsdl are small enough that I can tweak them to adhere to this rules.
However, like Ron, I've also been in situations where the easiest thing is just to live with it.
Hope this helps.
I am in the same situation (contract-first) and svcutil is generating this same kind of code for me but I just closed my eyes took a deep breath and accepted it :-)
Just use the types without the numeric postfix and it just works.
I try to import some valid schema (for xmlspy and oxygen) with XMLMapper in delphi and I have this error
"Error Flux if:InfofileType unknown".
I use namespace and this type is define in another file.
Is there a way to solve this ?
(I also try with Delphi 2010 demo and it still not work)
<?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:if="http://www.gtest.fr/Apps/InfoFile" xmlns:ca="http://www.gtest.fr/Apps/CommandAnswer" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.gtest.fr/Apps/InfoFile" schemaLocation="InfoFile.xsd" />
<xs:import namespace="http://www.gtest.fr/Apps/CommandAnswer" schemaLocation="CommandAnswer.xsd" />
- <xs:element name="ServerAnswer">
- <xs:annotation>
<xs:documentation>Reponse serveur socket</xs:documentation>
</xs:annotation>
- <xs:complexType>
- <xs:sequence>
<xs:element name="InfoFile" type="if:InfoFileType" />
<xs:element name="Command" type="ca:CommandAnswerType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
reported in QC : http://qc.embarcadero.com/wc/qcmain.aspx?d=80124
I would still try to grab a Delphi 2010 (trial) and see if it works there.
I know there has been significant work done there in D2009 and D2010. It was notoriously bad at doing imports and includes.
Much better now...
If you cannot solve this, I would recommend to manually edit the schemas to remove the include/import and build a big fat XSD without the external file. It should work better.
That's how I did with a rather intricate set of schemas that even .Net lib would choke on.
Update: Could you try to replace the if:InfoFile by another symbol to avoid any clash with the if reserved word; i.e. search 'n' replace if in the schemas by _if_ or anything else... The XML mapper is supposed to care of this but, ya know...
Eric Thorniley finally give me the way to go here.
It seems XML Mapper does not
understand the namespaces correctly.
You can however coax it into life by
adding an extra namespace definition
into the imported files. This is, I am
sure, not right.
So, for instance, in your
Insurance.xsd you declare
xmlns:Utils="http://www.gtest.fr/Apps/Utils"
If you add exactly the same definition
into Utils.xsd, XML Mapper imports it
correctly (I think!)
Ther is a fair chance that XML Spy
would strip out my modifications -
certainly Enterprise Architect ignores
them completely.
I'd like to see the message that Eric Thorniley pointed you to, but it is no longer there. I might be able to find it in an archive somewhere, if I had the subject of the message. I tried a Google search but all I found were duplicate copies of this post on different sites.
Thanks