[Xml-compile] ignoring an invalid xml response

Mark Overmeer mark at overmeer.net
Fri Jul 16 09:49:34 GMT 2010


* Pete Groff (pfg104 at gmail.com) [100713 19:29]:
> I'm calling a Share Point web service and get the following error:  "error:
> data for element or block starting with `Privacy' missing at {http://
> microsoft.com/webservices/SharePointPortalServer/UserProfileService}
> GetUserProfileByNameResponse/GetUserProfileByNameResult/PropertyData."  In
> looking at the wsdl and the response in SoapUI, the service is not returning
> the "Privacy" element even though it is defined as required by the wsdl.  How
> can I ignore such errors in XMC.  My code:

I have seen these problems before. The XML standard says: you MUST
reject everything which does not validate. However, often people turn
validation off for performance reasons and then break the message
structure accidentally. I have encountered more MicroSoft servers which
produce messages which do not validate :-((

My best guess is that you have a different version of the WSDL as the
server software used when it generated the objects. Versioning via
namespace in XML is a broken concept, but ignoring versions is bad
as well.

But how to resolve this?  I have considered adding an option like
   interpret_required_as_optional => 1
  (like I already have an interpret_nillable_as_optional, because some
   servers think that those are the same)
however, interpreting all minOccurs=1 as minOccurs=0 would probably
cause wrong choices on many spots.

You may try to convince Microsoft that their server is broken. Little
chance that will bring help.

So, the dirty trick is probably to patch the WSDL. You can add schemas
which overwrite WSDL definitions.

   $wsdl->importDefinitions( <<'_PATCH' )
   <schema ...>
   </schema>
   _PATCH

Hopefully, the number of mistakes is small and the data-structure
you have to recreate is small as well...

> my $transporter = XML::Compile::Transport::SOAPHTTP->new
>     (    address => $service_address,
>         keep_alive => 1
>         );
> my $http = $transporter->compileClient(
>     action => 'http://microsoft.com/webservices/SharePointPortalServer/
> UserProfileService/GetUserProfileByName'
> );

On the above, why do you need it?  Is there a mistake with the action
string or such?  Maybe I need to improve X::C::SOAP?

> my $wsdl = XML::Compile::WSDL11->new("$w");

Quotes around $w are superfluous.

> I see that in XMC::Schema, there is a validation flag for the compile method,
> but how would I get similar behavior in the code above?

  my $wsdl = XML::Compile::WSDL11->new
    ( $wsdl_filename
    , opts_rw => [ sloppy_integers => 1, validate => 0 ]
    );

-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list