I'm writing three different web services in three wsdls. The services all share a common type of generic error message. The three services are defined in three different namespaces but I want the error message to be defined in a fourth namespace. Is there a way to "import" or "include" the message-type into the three wsdl-files?
Yes, that should be possible. Use the <import> element to import the shared WSDL, in the portType's operation, you can fully qualify the name of message, i.e. you need to bind the fourth namespace to a prefix (e.g. ns4) and then add a reference like this:
<portType name="MyPortType">
<operation name="MyOperation">
<input message="tns:myInput"/>
<output message="tns:myOutput"/>
<fault message="ns4:myFault"/>
</operation>
</portType>
See http://www.w3.org/TR/wsdl#_style for further reference about the import mechanism.
Related
I recently tried binding based on RFC 6120 (9.1.3 pg 132) with:
<iq id='tn281v37' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></iq>
I would get a response of 'not well formed':
<stream:error xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>
It took a few days to find out it needed xmlns='jabber:client' :
<iq id='tn281v37' type='set' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></iq>
It doesn't look like RFC 6120 has been superseded and every example of binding I find on the web doesn't have it. Is this due to implementation of the server? At the time I was binding to chinwag.im
This appears to be a misunderstanding of how XML namespaces work. In one of your comments you suggested that you are using a namespace of jabber:socket, but this is not a namespace that is defined anywhere in the XMPP specs and I could not find any reference to it online. Instead, you want to use jabber:client (or jabber:server if this were a server-to-server connection). A quick overview of XML namespaces is below:
All XML elements have a "name", this name is made of two parts: the local name and the namespace. The namespace is defined using an xmlns attribute, for example the following are different elements, they do not have the same name:
<iq xmlns="jabber:client"/>
<iq xmlns="jabber:server"/>
Namespaces declared using an xmlns attribute are inherited by their child elements (unless that element has its own xmlns attribute), therefore in the following:
<session xmlns="jabber:client">
<iq/>
<foo xmlns="bar"/>
</session>
Both the "session" element and the "iq" elements have the namespace "jabber:client" but "foo" has the namespace "bar".
There is also another way to declare a namespace: using a prefix. Prefixes are declared with an "xmlns:prefix" attribute (where "prefix" is the name of the prefix). The list of prefixes is inherited by child elements and don't need to be redeclared, and the namespace defined by the prefix only applies to elements that start with "prefix:". For example:
<stream:stream xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams">
<iq/>
<stream:error></stream:error>
</stream:stream>
In the above the "stream" element has the namespace "http://etherx.jabber.org/streams", because it has the "stream:" prefix. The "iq" element on the other hand has the "jabber:client" namespace because it inherits it from the parents "xmlns" attribute. Finally, the "error" element also has the "http://etherx.jabber.org/streams" namespace because it uses the "stream:" prefix as well. Notice that it did not have to redeclare the stream prefix because it also inherits a list of prefixes from its parent elements, so just applying the prefix without re-defining it is okay.
It's impossible to tell from the level of detail you provided, but chances are you need to add xmlns="jabber:client" to your root element. If you don't have a root element to add it to (ie. when you're using the websocket protocol that sends lot of separate XML documents instead of one long stream), you will have to apply it separately to the root element in every frame you send.
With gdbus codegen, a struct/object is defined as a complete type in the xml like below
<method name="GetInfo">
<arg direction="out" type="(sib)" name="info"/>
</method>
However, if the same struct is used at multiple places, repeating the type definition is a bit painful, especially when the signature changes later on.
<method name="GetInfoList">
<arg direction="out" type="a(sib)" name="info_list"/>
</method>
So, is there a way to define an alias or a something for structs that we don't have to maintain the same thing at multiple places? Oh, and using Qt bindings is not an option in this case unfortunately.
Regards,
So, is there a way to define an alias or a something for structs that we don't have to maintain the same thing at multiple places?
No, there is not. That’s one of the disadvantages of using gdbus-codegen. If you want to define a struct for each of the D-Bus types in your API, you need to implement your service/client manually, without gdbus-codegen, using functions like g_dbus_connection_register_object().
I have a very simple problem of DI, and wanted to know if there is a way to solve it using Ninject (or any other DI helper).
I have a Data Access interface that is implemented by several Data Sources providers, like DB, Sharepoint, CRM, etc.
I want to use Ninject to get a specific instance of the interface, based on a parameter that contains a code representing one of this implementations.
So far I know that I can do that by using named bindings , but I couldn't find a way to do the same by xml config file (Ninject.extensions.xml).
Ninject extensions xml provides a way to solve single mappings:
<module name="SomeModule">
<bind service="Game.IWeapon" to="Game.Sword"/>
<bind service="Game.IWarrior" toProvider="Game.SamuraiProvider"/>
</module>
I'd like to do a config like that, but using multiple mappings for the same interface, using a name, a code or the like.
TIA,
Milton
Just add a name property
<bind service="Game.IWeapon" to="Game.Sword" name="sword"/>
<bind service="Game.IWeapon" to="Game.Dagger" name="dagger"/>
I have one property file linked both ways (using f:loadBundle and faces-config.xml) both with different var names. So it would look like the following:
datatypes.properties:
A=first
B=second
C=third
faces-config.xml:
<resource-bundle>
<base-name>datatypes</base-name>
<var>myProp</var>
</resource-bundle>
myPage.xhtml:
<f:loadBundle basename="datatypes" var="prop"/>
in myPage.xhtml I make a list of all the keys from the property file. What I can't seem to understand is that when I use #{prop} in the code below it works but when I replace it with #{myProp} the list no longer displays.
<h:form>
<h:selectManyListbox id="list">
<f:selectItems value="#{myProp}"></f:selectItems>
</h:selectManyListbox>
</h:form>
I figure this means the variables in both cases are not the same behind the scenes but I would appreciate it if someone could explain (or point me to an explaination) in what way they are different. I would ideally like to just use #{myProp} without having to pull the keys out in code and store them in a list.
Thanks.
Both <f:loadBundle> and <resource-bundle> are different ways to load properties with difference being in their access scopes. The latter has by the way the additional benefit that the bundle is also injectable in a managed bean by #ManagedProperty("#{myProp}")
Using <resource-bundle> in faces-config.xml creates a global resource bundle which can be accessed anywhere in your application. This is implemented through a java.util.ResourceBundle instance.
Using <f:loadBundle> in your view creates a view-specific resource bundle which is accessible only within that view. The tag handler implements this using an internal implementation of a Map. This is as specified in the VDL of the tag:
Load a resource bundle localized for the Locale of the current view,
and expose it as a java.util.Map in the request attributes of the
current request under the key specified by the value of the "var"
attribute of this tag.
Now since you're trying to use the values from datatypes.properties through <f:selectItems>, you'll get the said exception. This is because the value attribute for the tag should evaluate to a Collection or an array.
Value expression pointing at any Collection or array. The member
elements may be instances of SelectItem or any Java Object.
So in order to use the global bundle instance, you first have to convert the same into a List<SelectItem> inside your backing bean before using it.
NOTE: You can verify the above cases by setting a breakpoint in the initializeItems(Object) method in the com.sun.faces.renderkit.SelectItemsIterator class. This is, of course, assuming that you're using the Mojarra implementation.
When I try to publish my Workspace in RAD, I get this error "Two classes have the same xml type name", probably because the same class name exists in the same package, but in two different jars. And it seems like that the #XmlType annotation needs to have distinct values for its attributes name and namespace in the sources of these classes. I tried wsdl2java available in Apache CXF, but I'm not able to make it generate this namespace attribute. I tried fiddling with the -p package option, but that's only for placing the generated sources in the specified package.
Any ideas how to generate this namespace attribute for each element encountered in the wsdl? TIA.
thanks to Daniel's anwser:
CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
i learned there is a parameter -xjc-npa for wsdl2java which helped me.
This will add XmlType.name and XmlType.namespace annotations to the generated classes so it won't be a problem if you have same class names but in different namespaces
I ran into this for an object named "SubmitDataResponse" that I was using as a return object from my web service method named "submitData". When I tried renaming the object, the error went away. It seems to me that CXF is creating its own return object based on the method name (in this case submitData() -> "SubmitDataResponse"). You may want to try renaming the class and see if you are having the same issue. Perhaps someone can chime in with a way to keep our class named the way we want them to (probably with some annotation).
I hope this helps.