File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Invoking CrmService from Java Client problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Invoking CrmService from Java Client problem " Watch "Invoking CrmService from Java Client problem " New topic
Author

Invoking CrmService from Java Client problem

Wojtek Maka
Greenhorn

Joined: Sep 30, 2010
Posts: 6
Hello,

Maybe someone has faced this problem here. Here is the thing: I have generated stubs from CrmServiceWsdl using Axis 1.4 and it works well until I want to create some relations between entities. This cannot be achieved because the Lookup class which allows defining such relations doesn't have a value property (which should be GUID of an related entity). Simply saying : Axis hadn't generated all needed code. the Key, CrmReference, Lookup class are missing field for setting unique guids.

Best regards
Wojtek Maka
Greenhorn

Joined: Sep 30, 2010
Posts: 6
I have figured out that WSDL2Java tool of Axis 1.4 should generate a Guid class in com.microsoft.wsdl.types namespace but even such a package is not present in my generated codes.
Wojtek Maka
Greenhorn

Joined: Sep 30, 2010
Posts: 6
Ok, I decided to move to Axis2. Now the WSDL2java generator has generated all needed classes, there is this Guid class and everything would be fine but... the code below doesn't work. In my opinion everything is made correctly but the response is "server was unable to process the request"



This produces :

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'S' (code 83) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:118)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.microsoft.schemas.crm._2007.webservices.CrmServiceStub.Execute(CrmServiceStub.java:2271)
at Test.main(Test.java:103)
Caused by: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'S' (code 83) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:260)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:161)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:110)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:682)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:210)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:140)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:103)
... 7 more
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'S' (code 83) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:623)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
at org.apache.axiom.om.impl.builder.SafeXMLStreamReader.next(SafeXMLStreamReader.java:183)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:597)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
... 13 more

Now I've stuck and can not move forward,
So If anybody had similar problem and solved it, or if anybody thinks that he can help me - please post the answers


Also, I've tried some other request to execute but always the same result
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Wojtek,
Your problem seems to be because of program trying to build a malformed request SOAP message. Based on your code, I can't make out where the problem is. Is this exactly the same code you are using or have you altered with dummy string literals before posting? At this stage I can give some pointers. One of the problem areas is using special characters in your string literals without escaping! For e.g. str.setCondition("5<4"); '<' here has to be escaped like & l t ; (no space in between).


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Wojtek Maka
Greenhorn

Joined: Sep 30, 2010
Posts: 6
Naren Chivukula wrote:Hi Wojtek,
Your problem seems to be because of program trying to build a malformed request SOAP message. Based on your code, I can't make out where the problem is. Is this exactly the same code you are using or have you altered with dummy string literals before posting? At this stage I can give some pointers. One of the problem areas is using special characters in your string literals without escaping! For e.g. str.setCondition("5<4"); '<' here has to be escaped like & l t ; (no space in between).


No no, this is not because of this. The problem is with any type of request, even with those which do not need to set any additional information (eg. WhoAmI). I assume my client was successfully authenticated by server because there is no 401 response and so on. I really have stuck here .
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Wojtek,
Can you tell where this exception is originated (server or client)? If on server, is it possible to post SOAP message your are trying to generate?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invoking CrmService from Java Client problem