ERROR: soap:Client Unexpected wrapper element

9,192 views
Skip to first unread message

ILim

unread,
Sep 22, 2014, 3:18:22 PM9/22/14
to fedora-c...@googlegroups.com

Hello,

I can't seem to get API-M to work in my perl script (see below) for fedora 3.7.  I get:

"ERROR: soap:Client Unexpected wrapper element {http://www.fedora.info/definitions/api/}getDatastreamHistory found.   Expected {http://www.fedora.info/definitions/1/0/types/}getDatastreamHistory."

and fedora.log shows the following:

WARN 2014-09-22 14:35:42.517 [http-8080-2] (PhaseInterceptorChain) Interceptor for {http://www.fedora.info/definitions/1/0/types/}Fedora-API-M-Service#{http://www.fedora.info/definitions/1/0/types/}getDatastreamHistory has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element {http://www.fedora.info/definitions/api/}getDatastreamHistory found.   Expected {http://www.fedora.info/definitions/1/0/types/}getDatastreamHistory.

The same script works with my older version of fedora (3.2)  but not with my new install (3.7).  I haven't been able to find a fix for this online. Has anyone encountered this error or know how to fix it?  Thank you!

====================================================================

#!/usr/bin/perl

use SOAP::Lite;

my $management=SOAP::Lite
        -> uri('http://www.fedora.info/definitions/api/')
        -> proxy('http://USERNAME:PASSWORD@localhost:8080/fedora/services/management');

my $result=$management->getDatastreamHistory("P:100005","DS1");

if ($result->fault) {
     die "ERROR: " . $result->faultcode . " " . $result->faultstring . " " . $result->faultdetail . "\n";
}

my @datastreams = $result->paramsall();

foreach my $i ( 0 .. $#datastreams ) {
     foreach my $key (keys %{$datastreams[$i]}) {
        print "\n $i: $key: $datastreams[$i]{$key}";
     }
}

 

====================================================================

Ben Companjen

unread,
Sep 23, 2014, 4:30:40 AM9/23/14
to ILim, fedora-c...@googlegroups.com
Hi ILim,

It looks like the namespace of the wrapper element is not what the API expected. This may have changed between v3.2 and v3.7 though I haven't looked this up.

Have you tried replacing `uri('http://www.fedora.info/definitions/api/')` with `uri('http://www.fedora.info/definitions/1/0/types/')`?

Regards,

Ben
22 september 2014 21:18
--
You received this message because you are subscribed to the Google Groups "Fedora Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fedora-communi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ivy Lim

unread,
Sep 23, 2014, 10:25:19 AM9/23/14
to Ben Companjen, fedora-c...@googlegroups.com
Hi Ben,

Thanks so much for your reply.  I tried 'uri('http://www.fedora.info/definitions/1/0/types/')' and got the following message:

ERROR: soap:Client Unmarshalling Error: unexpected element (uri:"http://www.fedora.info/definitions/1/0/types/", local:"c-gensym3"). Expected elements are <{}dsID>,<{}pid> 

I also tried 'uri('http://www.fedora.info/definitions/1/0/api/')'  and got the same "Unexpected wrapper element" as before.

If you have any more pointers please let me know as I have been stumped on this for a week now and can't seem to find a solution online.

Thanks again!

Ben Companjen

unread,
Sep 24, 2014, 4:16:01 AM9/24/14
to Ivy Lim, fedora-c...@googlegroups.com
Hi Ivy,

Okay, you're one step further :)
The message you get tells me the XML in the SOAP request does not conform to the schema the API-M expects. At this point, the XML parser that parses your request expects elements <dsID> and <pid> without namespaces. It seems to be getting <c-gensym3>. Your script may look at the wrong WSDL file and therefore not know what to send. Have you seen the correct URL and the warning at [0]? :)

(I was going to suggest looking at a Perl library for talking to the API-M [1], but noticed that it doesn't support getDatastreamHistory...)

Groeten van Ben

[0] https://wiki.duraspace.org/display/FEDORA37/API-M#API-M-WSDLwsdl
[1] http://search.cpan.org/~dfielding/FedoraCommons-APIM-0.6/lib/FedoraCommons/APIM.pm
23 september 2014 16:25

hugh.barnard

unread,
Oct 14, 2014, 6:59:14 AM10/14/14
to fedora-c...@googlegroups.com, ivy...@gmail.com
Hi folks

Sorry to top post, but very similar problem. I'm working with a Perl front end and API-M + LDAP to login. Previously in the interface to 3.3.x the endpoints were configured by the front end configuration file. I'm now trying to upgrade to 3.8 as 3.7.x didn't really work

So I'm now getting:
Unexpected wrapper element {https://fedora.phaidra-test.univie.ac.at/fedora38/services/management}getNextPID found.  
Expected {http://www.fedora.info/definitions/1/0/types/}getNextPID.',

I've tried modfying the Fedora-API-M.wsdl (causes a Java error) and also in jaws.xml
 <!-- <entry key="schema-validation-enabled" value="${ws.soap.validation}" /> --> turn off schema validation, I 'hope'...

Neither works. I suspect this, in the fedora.log is connected:
DEBUG 2014-10-14 12:22:56.393 [localhost-startStop-1] (ConfigurerImpl) Could not find a definition for bean with id {http://www.fedora.info/definitions/1/0/types/}Fedora-API-M-Port-SOAPHTTP.jaxws-endpoint - no injection will be performed.
DEBUG 2014-10-14 12:22:56.393 [localhost-startStop-1] (ConfigurerImpl) Could not find a definition for bean with id org.apache.cxf.jaxws.JaxWsServerFactoryBean - no injection will be performed.
INFO 2014-10-14 12:22:56.429 [localhost-startStop-1] (ReflectionServiceFactoryBean) Creating Service {http://www.fedora.info/definitions/1/0/types/}Fedora-API-M-Service from WSDL: /usr/local/fedora38/server/management/Fedora-API-M.wsdl
DEBUG 2014-10-14 12:22:56.674 [localhost-startStop-1] (JAXBDataBinding) Created JAXBContext "jar:file:/usr/local/fedora38/tomcat/webapps/fedora38/WEB-INF/lib/jaxb-impl-2.1.3.jar!/com/sun/xml/bind/v2/runtime/JAXBContextImpl.class Build-Id: 2.1.3

Altering the namespace in the wsdl, should be 'cleanest' for this?

Best regards Hugh

hugh.barnard

unread,
Oct 15, 2014, 5:55:48 AM10/15/14
to fedora-c...@googlegroups.com, ivy...@gmail.com
Hi folks


I've turned on the trace in SOAP::LITE, here the sequence I'm getting:

SOAPAction: "http://www.fedora.info/definitions/1/0/types/#getNextPID"

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/enc
oding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/so
ap/envelope/"><soap:Body><getNextPID xmlns="http://www.fedora.info/definitions/1/0/types/"><numPIDs xsi:type="xsd:nonNegativeInteger">1</numPIDs><pidNamespace xsi:type="xsd:string">o</pidNamespace></getNextPID></soap:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x7fcd14c85ac8)
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error
Connection: close
Date: Wed, 15 Oct 2014 09:48:14 GMT
Server: Apache/2.2.15 (CentOS)
Content-Length: 370
Content-Type: text/xml;charset=UTF-8
Client-Date: Wed, 15 Oct 2014 09:48:47 GMT
Client-Peer: 131.130.1.211:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=NL/O=TERENA/CN=TERENA SSL CA
Client-SSL-Cert-Subject: /OU=Domain Control Validated/CN=phaidratest.univie.ac.at
Client-SSL-Cipher: AES128-SHA256
Client-SSL-Warning: Peer certificate not verified
Set-Cookie: JSESSIONID=F2AF877C67668E976F59F258CB925EF4; Path=/fedora38/; Secure; HttpOnly

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Err
or: unexpected element (uri:"http://www.fedora.info/definitions/1/0/types/", local:"numPIDs"). Expected elements are &lt;{}numPIDs&gt;,&lt;{}pidNamespace&gt;
 </faultstring></soap:Fault></soap:Body></soap:Envelope>
SOAP::Deserializer::deserialize: ()

Actually the sent message looks like it conforms to the types definition? I don't currently understand, how the 'expected elements' should be formatted:
unexpected element (uri:"http://www.fedora.info/definitions/1/0/types/", local:"numPIDs"). Expected elements are &lt;{}numPIDs&gt;,&lt;{}pidNamespace&gt;

When that is a little clearer, at the worst, I can make some kind of custom serializer. However, this does work without complaint in the 3.3.x series and seems problematic in 3.8 snapshot.

Best regards Hugh

Ralf Claussnitzer

unread,
Oct 16, 2014, 11:55:27 AM10/16/14
to fedora-c...@googlegroups.com
Hi,

I had a similar Problem when extending the SWORD service recently. It very much matters, what parameters have been used for the SOAP Stub code generation. I was able to track the problem down to the point where it was about how Arrays are wrapped (or not wrapped).

I don't really understand this, but I managed to get it working by re-generating my Java client code (there are tons of ways to do this) and using horrible-looking API calls:

https://github.com/slub/sword-fedora/blob/master/src/main/java/org/purl/sword/server/fedora/CRUDFedoraServer.java#L100

Maybe this gives a hint?

Regards,
Ralf

hugh.barnard

unread,
Oct 17, 2014, 5:25:52 AM10/17/14
to fedora-c...@googlegroups.com, ralf.cla...@slub-dresden.de
Hi Ralf

Thanks, it maybe gets me a little nearer. I've been guessing that the {} in the complaint may mean it 'wants' something like a Java array. I'll carry on, iterating over various formats for the call.

Later on, I may raise an issue to get these simplified and documented so that they work easily for cross-language SOAP. Probably better [but we're not ready for that yet] would be give up SOAP for REST!

Thanks again Hugh

hugh.barnard

unread,
Oct 23, 2014, 5:34:03 AM10/23/14
to fedora-c...@googlegroups.com, ivy...@gmail.com
Hi folks

It's taken me quite a while, but I have a provisional, messy solution to this that may get to a neater one. I did a few things:

1. Downloaded and fired up soapui: http://www.soapui.org/ and pointed it at the WSDL for API-M to give me WSDL conformant xml for getNextPID
2. Filled in the blanks with 1 and the value for my namespace
3. Sent everything off with LWP rather than SOAP::Lite as this post: http://www.tek-tips.com/viewthread.cfm?qid=1028891

The current message that I'm using successfully is:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.fedora.info/definitions/1/0/types/">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:getNextPID>
         <numPIDs>1</numPIDs>
         <pidNamespace>o</pidNamespace>
      </typ:getNextPID>
   </soapenv:Body>
</soapenv:Envelope>

I'm not sure what's changed between the upgrades etc., but that currently gets me the PID I want. Obviously others don't want my 'o' namespace but I've left the complete example.

Best regards Hugh




On Wednesday, 24 September 2014 09:16:01 UTC+1, Ben Companjen wrote:

hugh.barnard

unread,
Jan 30, 2015, 9:02:33 AM1/30/15
to fedora-c...@googlegroups.com
Hi folks

I've posted this in the same thread, since it's another Perl/SOAP call problem for something that did work in an earlier release. Ingest function called via SOAP from perl front end, code not modified since 3.3 [working] now seems to have problems in 3.8:

WARN 2015-01-30 14:55:07.878 [TP-Processor1] (PhaseInterceptorChain) Interceptor for {http://www.fedora.info/definitions/1/0/types/}Fedora-API-M-Service#{http://www.fedora.info/definitions/1/0/types/}ingest has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element {https://barnarh9:xxx...@fedora.yyyyyy.univie.ac.at/fedora/services/management}ingest found.   Expected {http://www.fedora.info/definitions/1/0/types/}ingest.

It looks as though the SOAP endpoint is being 'absorbed' into the payload? I've dumped the whole SOAP object and the endpoint is in the right place.

Best regards Hugh

Benjamin Armintor

unread,
Jan 30, 2015, 12:04:56 PM1/30/15
to hugh.barnard, fedora-c...@googlegroups.com
Your SOAP client is using the API-M endpoint URL as the namespace for the operation. I don't know why this is the case. As far as I can tell, the WSDL at /fedora/wsdl?api=API-M makes no reference to the machine hosting the endpoint except as a XSD schema location.

For what it's worth, POSTing this content:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<types:getDatastream xmlns:types="http://www.fedora.info/definitions/1/0/types/">
<pid>demo:XML_TO_HTMLDOC</pid>
<dsID>RELS-EXT</dsID>
</types:getDatastream>
</soapenv:Body>
</soapenv:Envelope>

... to an appropriate 3.8.0 API-M endpoint (/fedora/services/management/getDatastream) with credentials returns:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getDatastreamResponse xmlns:ns2="http://www.fedora.info/definitions/1/0/types/"><datastream><controlGroup>X</controlGroup><ID>RELS-EXT</ID><versionID>RELS-EXT1.0</versionID><altIDs></altIDs><label>RDF Statements about this object</label><versionable>true</versionable><MIMEType>application/rdf+xml</MIMEType><formatURI>info:fedora/fedora-system:FedoraRELSExt-1.0</formatURI><createDate>2007-08-15T14:36:30.369Z</createDate><size>462</size><state>A</state><location xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"></location><checksumType>DISABLED</checksumType><checksum>none</checksum></datastream></ns2:getDatastreamResponse></soap:Body></soap:Envelope>

... so I don't see where your hostname is entering the equation. The only thing I can suggest based on what I'm seeing is what was requested further up-thread: Rebuild whatever stub you're using with the current WSDL location.

Regards,
Ben

--

Hugh Barnard

unread,
Jan 30, 2015, 12:24:02 PM1/30/15
to Benjamin Armintor, fedora-c...@googlegroups.com
Hi Ben

Thanks, it's reassuring to have someone check over my shoulder. Meanwhile, I think [because I'm not very expert with cxf] I have cxf detail logging enabled and this has shown up in fedora.log:

INFO 2015-01-30 18:14:49.778 [TP-Processor1] (Fedora-API-M) Outbound Message
---------------------------
ID: 2
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Unexpected wrapper element {https://barnarh9:xx...@fedora.yyyyy.univie.ac.at/fedora/services/management}ingest found.   Expected {http://www.fedora.info/definitions/1/0/types/}ingest.</faultstring>

      </soap:Fault>
   </soap:Body>
</soap:Envelope>
--------------------------------------

I can do what I did with getNextPID and build the message manually, but it would good to know why this happens on previously-ok interface code.

Thanks again, Hugh

Benjamin Armintor

unread,
Jan 30, 2015, 1:51:47 PM1/30/15
to Hugh Barnard, fedora-c...@googlegroups.com
That's the same message. Whatever is generating the request message is generating it with the wrong namespace. I think I have some example SOAP::Lite working, though- I'll post it as a top-level message.

- Ben 

Hugh Barnard

unread,
Jan 30, 2015, 2:58:44 PM1/30/15
to Benjamin Armintor, fedora-c...@googlegroups.com
Thanks again Ben, I'm stopping for the week now, it's 8pm in London, but anything you have will be welcome...
Reply all
Reply to author
Forward
0 new messages