Yes, it helps.

Thanks again. I own you one!
Alex

2010/8/17 Daniel Kulp <[email protected]>

> On Tuesday 17 August 2010 1:59:41 am Alex Labad wrote:
> > WOW, like a charm!!!
> >
> > Thanks, really really thanks. I have been trying for a long time before
> > crying for help!!!
> >
> > so.. summing up:
> >
> > when using BOI, the wrapped form is required.
>
> No, when using the BOI, you need to use the from that the BOI is in.  If
> you
> would have done:
>
> boi = boi.getUnwrappedOperation()
>
> to get the unwrapped BOI, then it probably would have also worked.   By
> default, the BOI's returned from the BindingInfo would be the wrapped form
> (as
> it appears in the WSDL).   To use the unwrapped form, you would need to
> pull
> that out.
>
> > As an alternative, we can use
> > the operationName and the wrapped Object as parameters for the invoke
> > operation...
>
> When using the operation name, it would use the form that normal
> "wsdl2java"
> would have generated.  In this case, it would be the unwrapped form.
> However, the client DOES have invokeWrapped(name, ..) if you want to force
> it
> to use the wrapped version.
>
>
> > Am I right? I'm not 100% sure that I got it understood.... but very
> > grateful, anyway.
>
> Hope the above helps.
>
> Dan
>
>
> >
> >
> >
> >
> >
> > 2010/8/16 Daniel Kulp <[email protected]>
> >
> > > I THINK your calls into the opInfo around:
> > > if (!operationToBeInvoked.isUnwrapped()) {
> > >
> > > may be confusing things.  If passing the BindingOperationInfo into the
> > > invoke,
> > > you have to use the input message for the BOI, not it's unwrapped form.
> > >
> > > To check this, change the line:
> > > clientImpl.invoke(operationToBeInvoked, myObject);
> > > to
> > > clientImpl.invoke("objectInput", myObject);
> > > and see if that helps at all.
> > >
> > >
> > > Dan
> > >
> > > On Thursday 12 August 2010 8:13:05 am Alex Labad wrote:
> > > > Hi all!
> > > >
> > > >
> > > >
> > > > I have a weird problem with cxf invoking external services: I can
> > > > handle the simple ones through the simple DynamicClientFactory,
> > > > generating the Client and invoking the services, it is ok.
> > > >
> > > >
> > > >
> > > > The problem comes with the Object parameters:
> > > >
> > > > In this case, the client generates the Beans, I fill them through
> > > > introspection, check the values as well, but when sending the
> > > > parameter,
> > >
> > > in
> > >
> > > > the server, it just receives an empty bean...
> > > >
> > > >
> > > >
> > > > Calling it from SoapUI, it works perfectly
> > > >
> > > > Calling from java: It doesn’t reveive anything (it receives a
> > > > SimpleBean, but null when calling the getName or getSurname).
> > > >
> > > > Any help? Ideas? Will be veeeery welcome!!! (Thanks in advance!!!!)
> > > >
> > > >
> > > >
> > > > Easier with the code? Here it is: (Attached is the WSDL)
> > > >
> > > >
> > > >
> > > > The Service: I did it with Axis2, for dynamic client testing . Where
> > > > SimpleBean is just a POJO with name and surname attributes, and their
> > > > getter and setters.
> > > >
> > > >
> > > >
> > > > *public* String secondObject(SimpleBean simpleBean) {
> > > >
> > > >             *if* (simpleBean != *null*) {
> > > >
> > > >                   *if* (simpleBean *instanceof* SimpleBean) {
> > > >
> > > >                   System.*out*.println("ES UNA simpleBean BEAN");
> > > >
> > > >                   System.*out*.println("name: "
> +simpleBean.getName());
> > > >
> > > >                   System.*out*.println("surname:
> > > > "+simpleBean.getSurname());
> > > >
> > > >             }
> > > >
> > > >                   *return* simpleBean.getName()  + " ------------ " +
> > > >
> > > > simpleBean.getSurname();
> > > >
> > > >             }
> > > >
> > > >             *return* "No input provided";
> > > >
> > > >       }
> > > >
> > > > And the JavaCode to call to the service
> > > >
> > > >
> > > >
> > > > JaxWsDynamicClientFactory factory =
> > >
> > > JaxWsDynamicClientFactory.*newInstance*
> > >
> > > > ();
> > > >
> > > > String methodName=”secondObject”;
> > > >
> > > >       List<String> bindingFiles = *new* ArrayList<String>();
> > > >
> > > >      bindingFiles.add("javabindings.xml");
> > > >
> > > >                 Client clientImpl = factory.createClient(wsdlUrl,
> > >
> > > Thread.*
> > >
> > > > currentThread*().getContextClassLoader(), bindingFiles);
> > > >
> > > >       Endpoint endpoint = clientImpl.getEndpoint();
> > > >
> > > >       ServiceInfo serviceInfo =
> > > >
> > > > endpoint.getService().getServiceInfos().get(0);
> > > >
> > > >       QName bindingName = *null*;
> > > >
> > > >                   *for* (BindingInfo binfo :
> serviceInfo.getBindings())
> > > >                   {
> > > >
> > > >                         *if* (binfo.getName().getLocalPart().indexOf(
> > > >
> > > > "Soap11") > -1) {
> > > >
> > > >                              bindingName = binfo.getName();
> > > >
> > > >                         }
> > > >
> > > >                   }
> > > >
> > > >
> > > >
> > > >                   BindingInfo binding =
> > > >
> > > > serviceInfo.getBinding(bindingName);
> > > >
> > > >                   BindingOperationInfo operationToBeInvoked = *null*;
> > > >
> > > >                   *for* (BindingOperationInfo operation :
> > > > binding.getOperations()) {
> > > >
> > > >
> > > > *if*(methodName.equals(operation.getName().getLocalPart())) {
> > > >
> > > >                              operationToBeInvoked = operation;
> > > >
> > > >                         }
> > > >
> > > >                   }
> > > >
> > > >
> > > >
> > > >                   *if* (operationToBeInvoked == *null*) {
> > > >
> > > >                         *throw* *new*
> > > >                         NoSuchMethodException(methodName);
> > > >
> > > >                   }
> > > >
> > > >
> > > >
> > > >                   System.*out*.println("Invoke, operation info: " +
> > > >
> > > > operationToBeInvoked );
> > > >
> > > >                   BindingMessageInfo inputMessageInfo;
> > > >
> > > >
> > > >
> > > >                   *if* (!operationToBeInvoked.isUnwrapped()) {
> > > >
> > > >                         //Operation uses document literal wrapped
> > > >                         style.
> > > >
> > > >                         inputMessageInfo =
> > > >
> > > > operationToBeInvoked.getWrappedOperation().getInput();
> > > >
> > > >                   } *else* {
> > > >
> > > >                         inputMessageInfo =
> > > >
> > > > operationToBeInvoked.getUnwrappedOperation().getInput();
> > > >
> > > >                   }
> > > >
> > > >
> > > >
> > > >                   List<MessagePartInfo> parts =
> > > >
> > > > inputMessageInfo.getMessageParts();
> > > >
> > > >                   *if* (parts.isEmpty()) {
> > > >
> > > >                         System.*out*.println("parts is empty. No
> > > >                         message
> > >
> > > !"
> > >
> > > > );
> > > >
> > > >                   } *else* {
> > > >
> > > >                         MessagePartInfo partInfo = parts.get(0); //
> > > >                         Input
> > > >
> > > > class is Order
> > > >
> > > >                         // Get the input class Order
> > > >
> > > >                         Class<?> param1Class =
> partInfo.getTypeClass();
> > > >
> > > >
> > > >
> > > >                         System.*out*.println("param1 is of Type: " +
> > > >
> > > > param1Class.getCanonicalName());
> > > >
> > > >                               Object myObject = *create*
> > > >
> > > > (param1Class.getCanonicalName());
> > > >
> > > >                              Method theMethod =
> > > >
> > > > myObject.getClass().getMethod("setTask", String.*class*);
> > > >
> > > >                              theMethod.invoke(myObject, "value1");
> > > >
> > > >                              Method theDayMethod =
> > > >
> > > > myObject.getClass().getMethod("setTheDay", String.*class*);
> > > >
> > > >                              theDayMethod.invoke(myObject, "value2");
> > > >
> > > >                               System.*out*.println("Testing the
> > >
> > > income.");
> > >
> > > >                              Method getter1 =
> > > >
> > > > myObject.getClass().getMethod( "getTask", *null*);
> > >
> > >  System.*out*.println(getter1.invoke(myObject,
> > >
> > > > * null*));
> > > >
> > > >                              Method getter2 =
> > > >
> > > > myObject.getClass().getMethod( "getTheDay", *null*);
> > >
> > >  System.*out*.println(getter2.invoke(myObject,
> > >
> > > > * null*));
> > > >
> > > >                              Object[] response =
> > > >
> > > > clientImpl.invoke(operationToBeInvoked, myObject);
> > > >
> > > >                              *return* *parseResponse*(response);
> > > >
> > > >                  }
> > >
> > > --
> > > Daniel Kulp
> > > [email protected]
> > > http://dankulp.com/blog
>
> --
> Daniel Kulp
> [email protected]
> http://dankulp.com/blog
>

Reply via email to