Unmarshalling error for input string

Getting unmarshalling Error: For input string: "" . It probably means that wsdl is unable to unserialize data. But my xml is well formatted. Why is the wsdl service choking on this xml? I am using...

Getting unmarshalling Error: For input string: "" . It probably means that wsdl is unable to unserialize data. But my xml is well formatted. Why is the wsdl service choking on this xml?

I am using Suds + python.
Here is the wsdl of the soap service:

<xs:element name="parameters">
    <xs:complexType>
    <xs:sequence>
        <xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
            <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" name="key" type="xs:string"/>
                <xs:element minOccurs="0" name="value" type="xs:anyType"/>
            </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
    </xs:complexType>
</xs:element>

Python code:

client = Client(url)
query = client.factory.create('query')
listval1 = {"key":"*:*","value":"*:*"}
query.parameters.entry = [listval1]
response = client.service.search(query)

XML msg created by suds:

<query>
   <parameters>
      <entry>
         <key>*:*</key>
         <value>*:*</value>
      </entry>
   </parameters>
</query>

I continue to get unmarshalling Error. Is this because xsi:type="ns0:string" is not added by suds to key and value? If yes then how to add it?

asked Nov 21, 2011 at 12:27

jerrymouse's user avatar

jerrymousejerrymouse

16.4k16 gold badges73 silver badges95 bronze badges

5

i got around this using the a MessagePlugin concept.

from suds.client import Client
from suds.plugin import MessagePlugin

class AnyTypePlugin(MessagePlugin):
    mapping = {
        'id': 'xsd:int',
        'title': 'xsd:string',
    }
    def marshalled(self, context):
        modified = False

        body = context.envelope.getChild('Body')
        query = body.getChild("query")
        if query: 
            params = query.getChild("parameters")
            if params:
                entries = params.getChildren("entry")
                if entries:
                    for entry in entries:
                        key = entry.getChild("key").getText()
                        if key in self.mapping:
                            attr = Attribute('xsi:type', self.mapping[key])
                            entry.getChild("value").append(attr)
                            modified = True
        if modified:
            xsd_attr = Attribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema')
            context.envelope.append(xsd_attr)

url = "some wsdl url"
client = Client(url, plugins=[AnyTypePlugin()])

this way you can control depending on what key you pass as an entry, you can correctly set the type.

answered Jan 27, 2012 at 21:14

David's user avatar

DavidDavid

1,0248 silver badges3 bronze badges

I’m getting this error:

Fatal error: Uncaught SoapFault exception: [soap:Client] Unmarshalling Error: cvc-type.2: The type definition cannot be abstract for element ns1:searchParameters. in src/Google/Api/Ads/Common/Lib/AdsSoapClient.php:200

OS: Linux (Debian)
PHP: 5.2.6-1+lenny16
libxml: 2.6.32
API: v201302
Library: 4.2.1
Apr 2, 2013 Delete comment Project Member #1 api.pmatthews
Hi Davis,

It seems likely that you’re getting this issue as $addXsiTypes is set to false, in the AdsSoapClient.php:

https://code.google.com/p/google-api-adwords-php/source/browse/src/Google/Api/Ads/Common/Lib/AdsSoapClient.php

Could you confirm that you no longer see errors if you set $addXsiType to true. To implement this, simply add the following line, at line 404:
$addXsiTypes = TRUE;

Cheers,

  • Paul, AdWords API Team.
    Status: MoreInfoNeeded
    Apr 3, 2013 Delete comment Adding XSI type to SOAP request needs to support parsing PHP version labels for PHP installations bundled with Ubuntu. #2 couponchiefs
    I was seeing the same error (Unmarshalling Error: cvc-type.2).

OS: Linux
PHP 5.2.6
Library: 4.2.1
API: v201302

I can confirm that setting $addXsiType to true in AdsSoapClient fixes the issues. Previously the xsi types were not getting added to the XML. Once they were added, everything worked fine.
Apr 3, 2013 Delete comment #3 couponchiefs
Unfortunately, when I manually set «$addXsiTypes = TRUE;», while some of the previous failed API calls now work, it now brings back the previous error that was supposed to be fixed with this release:
«Unmarshalling Error: cvc-elt.4.2: Cannot resolve ‘Selector’ to a type definition for element ‘ns1:serviceSelector’.»
For example, this error now shows up when running the GetKeywords script.

OS: Linux
PHP 5.2.6
Library: 4.2.1
API: v201302

Apr 4, 2013 Delete comment #4 davis.fridenvalds
If I set $addXsiType to TRUE as Paul suggested, I get another error:

Fatal error: Uncaught SoapFault exception: [soap:Client] Unmarshalling Error: cvc-elt.4.2: Cannot resolve ‘Paging’ to a type definition for element ‘ns1:paging’.

OS: Linux (Debian)
PHP: 5.2.6-1+lenny16
libxml: 2.6.32
API: v201302
Library: 4.2.1
Apr 4, 2013 Delete comment Project Member #5 api.pmatthews
Thanks for the additional info there Davis.

Can you tell me, what was the last working version of the API for you? And does it still work?

Cheers,

Paul.
Apr 4, 2013 Delete comment #6 davis.fridenvalds
The last working API version was v201206.
Apr 11, 2013 Delete comment #8 velimira
aving the same issue with
PHP Version 5.2.6-1+lenny10
libxml: 2.6.32
API: v201302
adx_api_php_lib_4.2.2

v201209 was working fine
Apr 11, 2013 Delete comment #9 davis.fridenvalds
We couldn’t wait any longer and upgraded our PHP to 5.3.3-7+squeeze15 and now it is working fine.
Apr 11, 2013 Delete comment #10 kmhoggatt
The workaround I found for this issue is this:

  1. Set «$addXsiTypes = TRUE;» on AdsSoapClient.php line 404.
  2. Update all of the getXsiTypeName() functions in each of the classes defined in /Util/ReportUtils.php to return a blank string. For example, in the Paging class definition, modify the function getXsiTypeName() to ‘return «»;’ instead of ‘return «Paging»;’. Do the same for Selector class, Predicate class, etc.

After doing this, lib version 4.2.2 works fine with PHP 5.2.6 and v201302.
Apr 12, 2013 Delete comment #11 velimira
Thanks, this worked
Jul 22, 2013 Delete comment #12 steve962
I ran into the same exact issue with lib version 4.4.0. The solution presented in comment #10, editing the ReportUtils.php module to change all the getXsiTypeName() calls to return empty strings worked for me, even though it meant changing the library, something I really hate to do. (But was necessary to get us updated so we were running again.)

PHP Version 5.2.4-2ubuntu5.17
libxml version: 2.6.31
API: v201306
adwords_api_php_4.4.0

We were upgrading from API v201209 using lib 3.2.1, which worked fine.

Sep 26, 2013 Delete comment Project Member #13 api.pmatthews
We’ll look into making this value configurable from the settings.ini

Regards,

  • Paul, AdWords API Team.

Ошибка распаковки: для входной строки: «»

Получающий unmarshalling Error: For input string: "" . Вероятно, это означает, что wsdl не может десериализовать данные. Но мой xml хорошо отформатирован. Почему сервис wsdl задыхается от этого xml?

Я использую Suds + python. Вот WSDL мыльной службы:

<xs:element name="parameters">
    <xs:complexType>
    <xs:sequence>
        <xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
            <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" name="key" type="xs:string"/>
                <xs:element minOccurs="0" name="value" type="xs:anyType"/>
            </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
    </xs:complexType>
</xs:element>

Код Python:

client = Client(url)
query = client.factory.create('query')
listval1 = {"key":"*:*","value":"*:*"}
query.parameters.entry = [listval1]
response = client.service.search(query)

XML-сообщение, созданное пеной:

<query>
   <parameters>
      <entry>
         <key>*:*</key>
         <value>*:*</value>
      </entry>
   </parameters>
</query>

Я продолжаю получать unmarshalling Error. Это потому что xsi:type="ns0:string" не добавляется пеной к key и value? Если да, то как это добавить?

1 ответы

я обошел это, используя плагин MessagePlugin концепция.

from suds.client import Client
from suds.plugin import MessagePlugin

class AnyTypePlugin(MessagePlugin):
    mapping = {
        'id': 'xsd:int',
        'title': 'xsd:string',
    }
    def marshalled(self, context):
        modified = False

        body = context.envelope.getChild('Body')
        query = body.getChild("query")
        if query: 
            params = query.getChild("parameters")
            if params:
                entries = params.getChildren("entry")
                if entries:
                    for entry in entries:
                        key = entry.getChild("key").getText()
                        if key in self.mapping:
                            attr = Attribute('xsi:type', self.mapping[key])
                            entry.getChild("value").append(attr)
                            modified = True
        if modified:
            xsd_attr = Attribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema')
            context.envelope.append(xsd_attr)

url = "some wsdl url"
client = Client(url, plugins=[AnyTypePlugin()])

таким образом вы можете контролировать, в зависимости от того, какой ключ вы передаете как запись, вы можете правильно установить тип.

Создан 27 янв.

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

python
suds

or задайте свой вопрос.

java.lang.Long is not unmarshalled (while primitive long works)

Steps to reproduce:
1. Create a RPC-LITERAL web service on a stateless session bean with a single method like this:
public ResultDTO compute(FilterDTO filter)
FilterDTO must contain a java.lang.Long id; property.
Annotated FilterDTO with @XmlAccessorType(XmlAccessType.FIELD)

2. Generate the wsdl file with org.apache.cxf.tools.java2ws.JavaToWS

3. Deploy the ear by including the wsdl file also (wsdlLocation is specified on the bean for @WebService)

4. Start the server and use a client to call the method. Having RPC-LITERAL the parameter must be not null in the request.
So FilterDTO must be instantiated. Do not assign any value to the id field (let it null).

Result:

16:40:36,317 INFO [STDOUT] DefaultValidationEventHandler: [ERROR]: For input string: «»
16:40:36,317 INFO [STDOUT] Location: line 1
16:40:36,323 WARN [org.apache.cxf.phase.PhaseInterceptorChain] Interceptor for

{http://ws.ro/}

ServiceFacadeService#

{http://ws.ro/}

compute has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: For input
string: «»
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:787) [:2.3.1]
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:628) [:2.3.1]
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:133) [:2.3.1]
……..
Caused by: javax.xml.bind.UnmarshalException

  • with linked exception:
    [javax.xml.bind.UnmarshalException: For input string: «»
  • with linked exception:
    [java.lang.NumberFormatException: For input string: «»]]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425) [:
    2.2]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362) [:2.2]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339) [:2.2]
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:764) [:2.3.1]
    Caused by: javax.xml.bind.UnmarshalException: For input string: «»
  • with linked exception:
    [java.lang.NumberFormatException: For input string: «»]
    … 46 more
    Caused by: java.lang.NumberFormatException: For input string: «»
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) [:1.6.0_23]
    at java.lang.Long.parseLong(Long.java:431) [:1.6.0_23]
    at java.lang.Long.valueOf(Long.java:525) [:1.6.0_23]
    at com.sun.xml.bind.DatatypeConverterImpl._parseLong(DatatypeConverterImpl.java:143) [:2.2]

11 votes

1 answers

Get the solution ↓↓↓

Solution:

The error is indicating that yourrunSearchReqeust structure (that is, your$searchFor) is missing information. The documentation you provided indicates that the signature of therunSearch() call would look like:

runSearchResponse runSearch(runSearch $runSearch)

Further, therunSearch datatype would contain one field of typeRunSearchRequest.

So you need a data structure that contains an element'runSearchRequest' which itself is another data structure that contains_searchId

Try:

$searchFor = array(
  'runSearchRequest' => array(
    "_searchId" => "11",
  )
);

And change your call to:

$response = $soapClient->runSearch($searchFor);

Or alternatively:

$response = $soapClient->__soapCall("runSearch", array($searchFor));

This will produce a SOAP XML request that closely matches the one from the doc:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:ns1="http://externalapi.business.footprints.numarasoftware.com/">
<SOAP-ENV:Body>
        <ns1:runSearch>
            <runSearchRequest>
                <_searchId>11</_searchId>
            </runSearchRequest>
        </ns1:runSearch>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

2023-01-14

Write your answer


969

votes

Answer

Solution:

Unmarshalling Error can happen due to two reasons:

  • Exception: Unmarshalling Error: null: If there are after key Spaces
  • Exception: Unmarshalling Error: For input string: "233,43": Because Amount must be 233.43


Share solution ↓

Additional Information:

Date the issue was resolved:

2023-01-14

Link To Source

Link To Answer
People are also looking for solutions of the problem: the requested url was not found on this server. xampp

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

Понравилась статья? Поделить с друзьями:
  • Unmanaged exception 0xc0000005 vegas pro как исправить
  • Unlocking please wait no username error code 63 unlock failed перевод
  • Unlocker error debug privileges
  • Unlock xiaomi error 1004
  • Unlock tool ошибка 0xc0000005