This is perfect. I'll write something like that! Thanks! Sent from my iPhone
On Jan 2, 2013, at 2:00 PM, Daniel Kulp <dk...@apache.org> wrote: > > On Jan 2, 2013, at 2:43 PM, Sergio E Felix Aparicio <a...@me.com> wrote: > >> Is there any way of knowing beforehand that a specific WSDL will require a >> wrappable object? Other WSDLs that we've used worked correctly (even with >> complexType elements and the invoke() method). The only difference I can >> tell is that they use xsd:all instead of xsd:sequence. Is this what triggers >> the wrappable object creation? > > Well, you could generate code and see what it generates. :-) > > You can also do: > > for (BindingOperationInfo op : > client.getEndpoint().getBinding().getBindingInfo().getOperations()) { > System.out.println(op.getName() + ": " + op.isUnwrapped()); > } > > to see what it's expecting. > > Dan > > > >> >> Sent from my iPhone >> >> On Jan 2, 2013, at 1:26 PM, Andrei Shakirin <ashaki...@talend.com> wrote: >> >>> Hi, >>> >>> As Dan already pointed: >>> Client.invoke() method expected unwrapped parameters (top xml element with >>> name equals to operation name is ignored). >>> Unwrapped method signatures will be also generated by default with >>> wsdl2java. >>> >>> If you would like to construct wrapped objects, you should use >>> Client.invokeWrapped() method: >>> ConfirmarPagos confirmar = new ConfirmarPagos(); >>> res = client.invokeWrapped("confirmarPagos", confirmar); >>> System.out.println("ConfirmarPagos response: " + res[0]); >>> >>> Cheers, >>> Andrei. >>> >>> From: Sergio E Felix Aparicio [mailto:a...@me.com] >>> Sent: Mittwoch, 2. Januar 2013 19:45 >>> To: Andrei Shakirin >>> Subject: Re: JaxWsDynamicClientFactory throws IllegalArgumentException >>> >>> Hey Andrei! >>> >>> Here is the way I invoke the service: >>> >>> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); >>> >>> >>> ClassLoader classLoader = DynamicFactoryTest.class.getClassLoader(); >>> >>> >>> Client client = >>> dcf.createClient("http://www.myweb.com/WebService/services/ConsultasPagosWSPort/wsdl/ConsultasWS.wsdl", >>> classLoader); >>> >>> >>> Object consultarPagosObject; >>> try { >>> consultarPagosObject = >>> Thread.currentThread().getContextClassLoader().loadClass("com.myweb.ConsultarPagos").newInstance(); >>> >>> >>> Method m = >>> consultarPagosObject.getClass().getMethod("setReferencia", String.class); >>> m.invoke(consultarPagosObject, "12345678901234567891"); >>> >>> >>> Method m2 = >>> consultarPagosObject.getClass().getMethod("setFacturador", String.class); >>> m2.invoke(consultarPagosObject, "001"); >>> >>> >>> Object[] o = client.invoke("consultarPagos", consultarPagosObject); >>> >>> >>> Notice that I use the complex object called consultarPagosObject, since the >>> WSDL tells me this object should be used as Input. Am I doing something >>> wrong? >>> >>> >>> Thanks! >>> >>> Sent from my iPhone >>> >>> On Jan 2, 2013, at 8:55 AM, Andrei Shakirin >>> <ashaki...@talend.com<mailto:ashaki...@talend.com>> wrote: >>> Hi, >>> >>> I cannot reproduce the problem. >>> The following code snippet successfully invokes the service using your wsdl: >>> >>> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); >>> Client client = dcf.createClient("Pagos.wsdl"); >>> >>> Object[] res = client.invoke("confirmarPagos", "test1", "test2", "test3", >>> "test4", "test5"); >>> System.out.println("ConfirmarPagos response: " + res[0]); >>> >>> The mock service implementation is invoked and returns Confirmacion object. >>> So the problem is definitely not a schema & wsdl. >>> >>> Do you invoke the service in the same way? >>> >>> Cheers, >>> Andrei. >>> >>> >>> >>> -----Original Message----- >>> From: Alos [mailto:a...@me.com] >>> Sent: Samstag, 29. Dezember 2012 04:50 >>> To: users@cxf.apache.org<mailto:users@cxf.apache.org> >>> Subject: Re: JaxWsDynamicClientFactory throws IllegalArgumentException >>> >>> Hey Andrei! >>> >>> Thanks for responding! >>> >>> The WSDL looks something like this: >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <definitions >>> name="ConsultasPagosWSService" >>> targetNamespace="http://www.myweb.com/" >>> xmlns="http://schemas.xmlsoap.org/wsdl/" >>> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" >>> xmlns:tns="http://www.myweb.com/" >>> xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" >>> xmlns:wsp="http://www.w3.org/ns/ws-policy" >>> xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" >>> 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"> >>> >>> <types> >>> <xs:schema targetNamespace="http://www.myweb.com/" >>> version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> >>> >>> <xs:element name="confirmarPagos" >>> type="tns:confirmarPagos" /> >>> >>> <xs:element name="confirmarPagosResponse" >>> type="tns:confirmarPagosResponse" /> >>> >>> <xs:element name="consultarPagos" >>> type="tns:consultarPagos" /> >>> >>> <xs:element name="consultarPagosResponse" >>> type="tns:consultarPagosResponse" /> >>> >>> <xs:complexType name="confirmarPagos"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="referencia" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="facturador" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="formadepago" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="estatus" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="folio" type="xs:string" /> >>> </xs:sequence> >>> </xs:complexType> >>> >>> <xs:complexType >>> name="confirmarPagosResponse"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="return" type="tns:confirmacion" /> >>> </xs:sequence> >>> </xs:complexType> >>> >>> <xs:complexType name="confirmacion"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="referencia" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="facturador" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="formadepago" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="estatus" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="folio" type="xs:string" /> >>> </xs:sequence> >>> </xs:complexType> >>> >>> <xs:complexType name="consultarPagos"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="referencia" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="facturador" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="estatus" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia1" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia2" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia3" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia4" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="fecha" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="importe" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia5" type="xs:string" /> >>> </xs:sequence> >>> </xs:complexType> >>> >>> <xs:complexType name="consultarPagosResponse"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="return" type="tns:consulta" /> >>> </xs:sequence> >>> </xs:complexType> >>> >>> <xs:complexType name="consulta"> >>> <xs:sequence> >>> <xs:element minOccurs="0" >>> name="referencia" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="facturador" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="estatus" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia1" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia2" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia3" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia4" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="fecha" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="importe" type="xs:string" /> >>> <xs:element minOccurs="0" >>> name="referencia5" type="xs:string" /> >>> </xs:sequence> >>> </xs:complexType> >>> </xs:schema> >>> </types> >>> <message name="confirmarPagos"> >>> <part element="tns:confirmarPagos" name="parameters"> >>> </part> >>> </message> >>> <message name="confirmarPagosResponse"> >>> <part element="tns:confirmarPagosResponse" >>> name="parameters"> >>> </part> >>> </message> >>> <message name="consultarPagos"> >>> <part element="tns:consultarPagos" name="parameters"> >>> </part> >>> </message> >>> <message name="consultarPagosResponse"> >>> <part element="tns:consultarPagosResponse" >>> name="parameters"> >>> </part> >>> </message> >>> <portType name="ConsultasPagosWS"> >>> <operation name="consultarPagos"> >>> <input message="tns:consultarPagos" >>> wsam:Action="http://www.myweb.com/ConsultasPagosWS/consultarPagos >>> Request"> >>> </input> >>> <output message="tns:consultarPagosResponse" >>> wsam:Action="http://www.myweb.com/ConsultasPagosWS/consultarPagos >>> Response"> >>> </output> >>> </operation> >>> <operation name="confirmarPagos"> >>> <input message="tns:confirmarPagos" >>> wsam:Action="http://www.myweb.com/ConsultasPagosWS/confirmarPagos >>> Request"> >>> </input> >>> <output message="tns:confirmarPagosResponse" >>> wsam:Action="http://www.myweb.com/ConsultasPagosWS/confirmarPagos >>> Response"> >>> </output> >>> </operation> >>> </portType> >>> <binding name="ConsultasPagosWSPortBinding" >>> type="tns:ConsultasPagosWS"> >>> <soap:binding style="document" >>> transport="http://schemas.xmlsoap.org/soap/http" /> >>> <operation name="consultarPagos"> >>> <soap:operation soapAction="" /> >>> <input> >>> <soap:body use="literal" /> >>> </input> >>> <output> >>> <soap:body use="literal" /> >>> </output> >>> </operation> >>> <operation name="confirmarPagos"> >>> <soap:operation soapAction="" /> >>> <input> >>> <soap:body use="literal" /> >>> </input> >>> <output> >>> <soap:body use="literal" /> >>> </output> >>> </operation> >>> </binding> >>> <service name="ConsultasPagosWSService"> >>> <port binding="tns:ConsultasPagosWSPortBinding" >>> name="ConsultasPagosWSPort"> >>> <soap:address >>> location="http://localhost:9080/WebService/services/ConsultasPagosWSPor >>> t" /> >>> </port> >>> </service> >>> </definitions> >>> >>> >>> >>> I'm using version 2.5 but have tried with the latest version 2.7.1. >>> >>> They way am using the client is about the same as the example shown here: >>> >>> JaxWsDynamicClientFactory dcf = >>> JaxWsDynamicClientFactory.newInstance(); >>> Client client = dcf.createClient("echo.wsdl"); >>> >>> Object[] res = client.invoke("echo", "test echo"); System.out.println("Echo >>> response: " + res[0]); >>> >>> >>> The application will fail as soon as invoke is called. The message is never >>> sent, >>> as the client throws an error when trying to create a wrappable object. I've >>> been poking at the XSD where the elements are described and have noticed >>> that if I replace <xs:sequence> with <xs:all> the wrappable object is not >>> created and everything will work. I can't however, ask the client to change >>> the XSD without making sure the XSD is really the problem (generating the >>> POJOS manually and calling the method works, for example, why wont the >>> dynamic client do the same?). >>> >>> Thank you for your time! =) >>> >>> ---- >>> >>> Sergio >>> >>> >>> On Dec 28, 2012, at 3:21 AM, Andrei Shakirin >>> <ashaki...@talend.com<mailto:ashaki...@talend.com>> wrote: >>> >>> Hi, >>> >>> Any chance to provide a wsdl, xsds and code snapshot how you create a >>> client? >>> Which CXF version are you use? >>> >>> Cheers, >>> Andrei. >>> >>> -----Original Message----- >>> From: Sergio E Felix Aparicio [mailto:a...@me.com] >>> Sent: Freitag, 28. Dezember 2012 04:24 >>> To: users@cxf.apache.org<mailto:users@cxf.apache.org> >>> Subject: Re: JaxWsDynamicClientFactory throws >>> IllegalArgumentException >>> >>> Anyone? >>> >>> >>> On Dec 23, 2012, at 2:59 PM, Sergio E Felix Aparicio >>> <a...@me.com<mailto:a...@me.com>> >>> wrote: >>> >>> >>> Hey guys! >>> >>> I've been struggling to get the JaxWsDynamicClientFactory to >>> correctly >>> parse a client's WSDL. I always get a IllegalArgumentException. I've >>> started debugging and found that somehow the problem goes back to the >>> JAXBDataBinding. >>> >>> It appears that the method: createWrapperHelper fails to create a wh >>> object and then attempts to create it again: >>> >>> if (wh == null) { >>> wh = new JAXBWrapperHelper(wrapperType, setMethods, >>> getMethods, jaxbMethods, fields, >>> objectFactory); >>> } >>> >>> The JAXBWrapperHelper fails again since the jaxbMethods is filled >>> with >>> nulls and its getPartObject(..) method always returns the full complex >>> object. >>> When the helper tries to call the setter methods to create the >>> wrapper object the IllegalArguementException is thrown. >>> >>> What causes CXF to start to create a wrappable object? What >>> specifically >>> happens in the WSDL that it makes Apache CXF try to create a wrapper >>> for the user owned object? >>> >>> Without going to NDA territory the WSDL is super simple: a "complex" >>> object with 5 String attributes. The object is defined in a separate >>> XSD document. >>> >>> I've tried to use the WSDL2Java and the resulting POJO is what you >>> would >>> expect. A single class with 5 String attributes. >>> >>> Help? > > -- > Daniel Kulp > dk...@apache.org - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com >