• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Need Help regarding -- org.xml.sax.SAXException: Invalid element

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am a Java/J2EE developer
I am currently working on integration between a CRM & an enterprise java application.
I want to access the CRM web service which is developed in .Net using the WSDL

I have generated the client side stubs using WSDL2JAVA.
The WSDL is generated on CRM server.
I am using apache axis 1.4

When i am trying to run my application I am getting following exception.
Can you please help me to resolve this

Regards
Harry


 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HowToGetHelpWithSoapWebServices
 
Harshad Khasnis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Peer, thanks for you response.
I followed the steps in the FAQ & also gone thru the discussion linked in the FAQ.

This the portion of the "mscrm.wsdl" relavent to our discussion.



I am providing the request & response from the tcpmon here.

Request --


Response --


Still I am getting the same exception.

Here is the class WhoAmIResponse in the discussion.


When I tried to debug the code, the found that the "getDeserializer" method for this class is not getting called instead the same method of the super class "Response" is getting called.
[ February 29, 2008: Message edited by: Harry Kirsten ]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harry

I'm getting the same org.xml.sax.SAXException: Invalid element error using Axis 1.4.

If you should happen to find the solution, I'd really appreciate it if you would post it.

Thanks so much.
Amy
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You excised relevant sections of the WSDL so I had to make some guesses:



This basically reproduced the SOAP request as you indicated. In retrospect I'm surprised that Axis managed to get the request right.

However the Axis server portion really failed when it turned


into



when it should have been



Basically the Serialization/Deserialization component does not seem to deal with XML Schema polymorphism correctly.
Axis has no trouble dealing with extended types like:



It just can't deal with them polymorphically (at least not at the SOAP payload/document level).

So basically Axis 1.x cannot consume this WSDL.

Interestingly enough Nicolai Josuttis states in SOA in Practice: The Art of Distributed System Design (p44):

Based on my own experience (and others), I recommend that you have a basic set of fundamental types that you can compose to other types (structures, records) and sequences (arrays). Be careful with enumerations (an anachronism from the time when each byte did count - use strings instead), inheritance and polymorphism (even when XML supports it).

 
Harshad Khasnis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi peer,
you are right. when i was debugging the code, i figured out that Axis has problem dealing with polymorphisms/inheritance.

I am really sorry about not giving the more portion about the WSDL, but the whole WSDL is very large and I cannot post it here.

Also I am not sure whatever you guessed is completely correct or not, if you are ok with it then i can send you the whole WSDL.

I cannot give the whole stub code here, but what i have understood is that, axis created the typeMappingRegistry for every request and response.

The mapping is done between superclass - subclass in the map it was maintained with classType - QName for our example it should be (Response - WhoAmIResponse)

When it is making the request this mapping is properly build (Request - WhoAmIRequest) and thus the apporpriate Serialiser & DeSerialiser gets called.

But when at the time of processing the response this mapping is not available. i.e the Map between classType - QName is empty, so axis is unable to determine which DeSerialiser to call, hence end up calling the DeSerialiser for the class Response.

I am still searching for the solution for this, if you can provide any input it will be great help.

Thanks for your help...really appreciate it.

Best Regards
Harry
[ February 29, 2008: Message edited by: Harry Kirsten ]
 
Harshad Khasnis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
I also tried using Axis2 and JAX-WS.
But there i faced another problem.
This WSDL is not just plain document/literal format but, .Net style - document/literal wrapped format, where you can found multiple part elements under message element, which is not the case in plain document/literal fomrat.

So when i tried to wsimport[JAX-WS] and WSDL2JAVA[Apache Axis2] i got the error = more than one part element fount for message element...
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Document/literal wrapped is a convention that was created to transfer more than one document per envelope. In a lot of cases it is used because people can't leave their RPC thinking behind in the document-oriented world (the type of document implies the operation - no operation name/method required). "Document/literal wrapped" basically allocates one request document type and one response document type per in-out host "RPC" method.

See: The "wrapped" document/literal convention

As far as I'm aware WS-I Basic Profile still only allows a single part per message in document/literal - regardless of whether it is bare or wrapped. Having more than one part breaches the interoperability protocol. The whole idea of document/literal is that the payload is a single document. If you need to ship more then one you have to use a holder document - a wrapper.
 
Harshad Khasnis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
Thanks for your response.
But, a even though going thru a lot of search & several articals, i am not able to find any solution for the problem.
Please check you PM i am sending the WSDL.

Can you please provide me some solution, or is there any alternative approch for the same. Integration between MS-CRM webservice & Java. I am really stuck with this.

Regards
Harry
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the message that is causing the problems.

There may be a bug somewhere that caused this to "leak through" because this is the only message the breaks the interoperability protocol. So the originators of the WSDL may need to be notified about this problem - and maybe they will take action to fix it.

In the meantime - I'm not sure how critical the Retrieve operation is to what you are trying to do (the name doesn't bode well - however maybe you'll be able to use the "RetrieveMultiple" method instead to retrieve a single instance in a collection) - you should be able to make some modifications to a copy of the WSDL to see if you can get the rest to work under Axis2/JAX-WS (Axis 1.x is a lost cause I'm afraid).
  • delete the RetrieveSoapIn and RetrieveSoapOut message
  • in the portType section delete the Retrieve operation
  • in the binding section delete the Retrieve Operation

  • Now try to generate a stub from modified WSDL.

    If you need access of the Retrieve method and a fix to the method isn't forth coming (fast enough) then you'll need to hand code the generation of the SOAP RetrieveSoapIn requests and the parsing of the RetrieveSoapOut responses on a separate client stub. In Axis2 this amounts to using org.apache.axis2.client.Call and building requests /parsing responses with org.apache.axis2.soap.SOAPEnvelope. Web services are supposed to have a stateless design - if yours does not then you will also need to code the SOAP interaction of the methods that are required to "build the state" required before you can call the Retrieve method. So basically
  • You have to identify the "Retrieve" interactions necessary for your client. You need to be specific enough so that you can code up representative scenarios in a tracer bullet/spike/vertical slice.
  • Use .NETs WSDL.exe to create a stub and code a minimal console app (in C# (or J#)) to exercise the representative scenarios. Capture the SOAP request/response pairs with tcpmon as your baseline input/output requirements for your Java based stub.
  • Now code up the scenarios one by one with your chosen Java API. As you go, refactor the interactions to a more generalized stub to be used by your client application.

  •  
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    # elemField.setFieldName("businessUnitId");
    # elemField.setXmlName(new javax.xml.namespace.QName("http://schemas.microsoft.com/crm/2006/WebServices", "BusinessUnitId"));

    Xml is case sensitive, so you must change the first or second row to "businessUnitId" or "BusinessUnitId", as long as it is the same.

    Regards,
    Pelle
     
    I want my playground back. Here, I'll give you this tiny ad for it:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic