Skip to main content

Default namespaces, MS CRM 2011 and JAXWS

2 replies [Last post]
matthew_d_wilson
Offline
Joined: 2006-11-28
Points: 0

Hi all!

I posted a very similar question back in 2010 and never found a solution (see http://www.java.net/node/702532 )

It's come back to haunt me again. At the risk of this getting way too long, here's some XML generated by jaxws for a certain request to a Microsoft CRM 2011 server (I've formatted it a bit):

<?xml version='1.0' encoding='UTF-8'?>


xmlns:ns2="http://schemas.microsoft.com/crm/2006/WebServices"
xmlns:ns3="http://schemas.microsoft.com/crm/2006/CoreTypes"
xmlns:ns4="http://schemas.microsoft.com/crm/2006/Query"
xmlns:ns5="http://schemas.microsoft.com/crm/2009/Query"
xmlns:ns6="http://schemas.microsoft.com/crm/2006/Scheduling"
xmlns:ns7="http://schemas.microsoft.com/crm/2007/CoreTypes"
xmlns:ns8="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:ns9="http://schemas.microsoft.com/crm/2009/WebServices">
0
RMSUA
00000000-0000-0000-0000-000000000000



xmlns:ns2="http://schemas.microsoft.com/crm/2006/WebServices"
xmlns:ns3="http://schemas.microsoft.com/crm/2006/CoreTypes"
xmlns:ns4="http://schemas.microsoft.com/crm/2006/Query"
xmlns:ns5="http://schemas.microsoft.com/crm/2009/Query"
xmlns:ns6="http://schemas.microsoft.com/crm/2006/Scheduling"
xmlns:ns7="http://schemas.microsoft.com/crm/2007/CoreTypes"
xmlns:ns8="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:ns9="http://schemas.microsoft.com/crm/2009/WebServices">



Here's the same request as created by a C# client consuming the same service as a web reference.

<?xml version="1.0" encoding="utf-8"?>
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">


0
RMSUA
00000000-0000-0000-0000-000000000000







The second one works. The first one doesn't. And it entirely comes down to the way the namespace is applied to the "Execute" element. If it is declared as the default namespace for that element, the request is processed. If not (say, it's declared and applied as a prefix) then it fails, MS CRM apparently just not seeing the request element at all. I can tweak that first piece of XML and add the necessary default NS decl to "Execute" and it works. That's all it takes.

This is clearly a bug in the MS CRM web service implementation (or its XML parsing). But there's not much I can do about that - all I know is the CIO wants this integration working again (*sigh*).

I've been poring over the source for JAXB and JAXWS for a few days, I've messed about a bit with the NamespacePrefixMapper property, and I can't find any way to customise this particular piece of XML serialisation behaviour. I can see glimpses of promise in the code here any there (although not under the "v2" package) but I can't work out how to get to them.

Can folks tell me if I should just give up trying to change the XML output to suit microsoft and just submit my requests to MS CRM as constructed XML strings? At this point, I'm just after whatever gets things working the quickest, and hang the elegance.

As an aside, I'm a bit baffled that MS can get away with this. It's obviously not a new problem, and I thought there were "plug fests" where integration between toolkits got tested. Yet their web service simply doesn't accept valid XML requests. How?

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
matthew_d_wilson
Offline
Joined: 2006-11-28
Points: 0

Well THAT worked. Let's see if I can escape this a bit ...

First XML snippet (doesn't work)

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<ns8:CrmAuthenticationToken
xmlns:ns2="http://schemas.microsoft.com/crm/2006/WebServices"
xmlns:ns3="http://schemas.microsoft.com/crm/2006/CoreTypes"
xmlns:ns4="http://schemas.microsoft.com/crm/2006/Query"
xmlns:ns5="http://schemas.microsoft.com/crm/2009/Query"
xmlns:ns6="http://schemas.microsoft.com/crm/2006/Scheduling"
xmlns:ns7="http://schemas.microsoft.com/crm/2007/CoreTypes"
xmlns:ns8="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:ns9="http://schemas.microsoft.com/crm/2009/WebServices">
<ns7:AuthenticationType>0</ns7:AuthenticationType>
<ns7:OrganizationName>RMSUA</ns7:OrganizationName>
<ns7:CallerId>00000000-0000-0000-0000-000000000000</ns7:CallerId>
</ns8:CrmAuthenticationToken>
</S:Header>
<S:Body>
<ns8:Execute
xmlns:ns2="http://schemas.microsoft.com/crm/2006/WebServices"
xmlns:ns3="http://schemas.microsoft.com/crm/2006/CoreTypes"
xmlns:ns4="http://schemas.microsoft.com/crm/2006/Query"
xmlns:ns5="http://schemas.microsoft.com/crm/2009/Query"
xmlns:ns6="http://schemas.microsoft.com/crm/2006/Scheduling"
xmlns:ns7="http://schemas.microsoft.com/crm/2007/CoreTypes"
xmlns:ns8="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:ns9="http://schemas.microsoft.com/crm/2009/WebServices">
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns8:WhoAmIRequest"/>
</ns8:Execute>
</S:Body>
</S:Envelope>

matthew_d_wilson
Offline
Joined: 2006-11-28
Points: 0

Excellent. Second XML snippet (DOES work). Sorry about this - I haven't posted here much.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">0</AuthenticationType>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">RMSUA</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<Request xsi:type="WhoAmIRequest" />
</Execute>
</soap:Body>
</soap:Envelope>