erlsom icon indicating copy to clipboard operation
erlsom copied to clipboard

error: 1 - Unexpected event, expected end-tag

Open lego12239 opened this issue 8 years ago • 8 comments

Hi.

Got the next error:

{error,{decoding,[{exception,{error,{"1 - Unexpected event, expected end-tag"}}},
                  {stack,['soap:detail','soap:Fault','soap:Body',
                          'soap:Envelope']},
                  {received,{characters,"Invalid login/pass"}}]}}

while processing the next soap xml response:

<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn://pmtv.digisoft.com/systemstatus/schema/v0.1" xmlns:ns3="urn://pmtv.digisoft.com/providerstatus/schema/v0.1" xmlns:ns5="http://schemas.microsoft.com/Message" xmlns:ns4="urn://pmtv.digisoft.com/uploadUsageRecords/wsdl/v0.1" xmlns:ns7="ws.kitd.vx2.ws.EntityNotification/EntityNotificationServiceSoap" xmlns:ns6="ws.kitd.vx2.ws.EntityNotification" xmlns:ns8="ws.kitd.vx2.ws.EntityNotification/EntityNotificationServiceSoap12" xmlns:ns11="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns12="http://schemas.datacontract.org/2004/07/GMCS.PMT.IntegrationInternal" xmlns:ns15="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns16="http://schemas.datacontract.org/2004/07/GMCS.PMT.IntegrationInternal" xmlns:ns9="http://GMCS/PMT/Integration" xmlns:lbapi="urn:api3">
    <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
        <faultcode>SOAP-ENV:Server</faultcode>
        <faultstring>error_request</faultstring>
        <detail>Invalid login/pass</detail>
      </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

If i add the next line:

error_logger:info_msg("~p~n~p~n", [Event, ElementRecord]),

near 444 line of erlsom_parse.erl (before a throw call), i get the next output:

{characters,"Invalid login/pass"}
{'soap:detail',[],undefined}

How can i eliminate this error?

Thanks.

lego12239 avatar Aug 21 '15 15:08 lego12239

Hello Oleg,

The reason for the error is that erlsom expects one or more elements as children of the tag, and not a text value.

The soap schema says:

<xs:complexType name="detail"> xs:sequence <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> /xs:sequence <xs:anyAttribute namespace="##any" processContents="lax" /> /xs:complexType

So a valid error could look like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ "> SOAP-ENV:Header/SOAP-ENV:Body SOAP-ENV:FaultSOAP-ENV:Client Message does not have necessary info http://gizmos.com/order <PO:order xmlns:PO="http://gizmos.com/orders/"> Quantity element does not have a value/PO:order <PO:confirmation xmlns:PO="http://gizmos.com/confirm"> Incomplete address: no zip code/PO:confirmation /SOAP-ENV:Fault /SOAP-ENV:Body/SOAP-ENV:Envelope

Regards, Willem

On Fri, Aug 21, 2015 at 5:05 PM, Oleg [email protected] wrote:

Hi.

Got the next error:

{error,{decoding,[{exception,{error,{"1 - Unexpected event, expected end-tag"}}}, {stack,['soap:detail','soap:Fault','soap:Body', 'soap:Envelope']}, {received,{characters,"Invalid login/pass"}}]}}

while processing the next soap xml response:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn://pmtv.digisoft.com/systemstatus/schema/v0.1" xmlns:ns3="urn://pmtv.digisoft.com/providerstatus/schema/v0.1" xmlns:ns5="http://schemas.microsoft.com/Message" xmlns:ns4="urn://pmtv.digisoft.com/uploadUsageRecords/wsdl/v0.1" xmlns:ns7="ws.kitd.vx2.ws.EntityNotification/EntityNotificationServiceSoap" xmlns:ns6="ws.kitd.vx2.ws.EntityNotification" xmlns:ns8="ws.kitd.vx2.ws.EntityNotification/EntityNotificationServiceSoap12" xmlns:ns11="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns12="http://schemas.datacontract.org/2004/07/GMCS.PMT.IntegrationInternal" xmlns:ns15="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns16="http://schemas.datacontract.org/2004/07/GMCS.PMT.IntegrationInternal" xmlns:ns9="http://GMCS/PM T/Integration" xmlns:lbapi="urn:api3"> SOAP-ENV:Body SOAP-ENV:Fault SOAP-ENV:Server error_request Invalid login/pass /SOAP-ENV:Fault /SOAP-ENV:Body /SOAP-ENV:Envelope

If i add the next line:

error_logger:info_msg("~p~n~p~n", [Event, ElementRecord]),

near 444 line of erlsom_parse.erl (before a throw call), i get the next output:

{characters,"Invalid login/pass"} {'soap:detail',[],undefined}

How can i eliminate this error?

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/willemdj/erlsom/issues/45.

willemdj avatar Aug 21 '15 17:08 willemdj

Thanks for the reply.

This is bad news, because i can't change a server side code. How can i say erlsom to accept the existent wrong format of detail element?

lego12239 avatar Aug 21 '15 18:08 lego12239

You can change the schema, so that is an element of type string. (If you also get "correct" faults it becomes a bit more complicated.)

On Fri, Aug 21, 2015 at 8:16 PM, Oleg [email protected] wrote:

Thanks for the reply.

This is bad news, because i can't change a server side code. How can i say erlsom to accept the existent wrong format of detail element?

— Reply to this email directly or view it on GitHub https://github.com/willemdj/erlsom/issues/45#issuecomment-133519665.

willemdj avatar Aug 21 '15 19:08 willemdj

If i'll replace here:

  <xs:element name="Fault" type="tns:Fault" />
  <xs:complexType name="Fault" final="extension" >
    <xs:annotation>
          <xs:documentation>
            Fault reporting structure
          </xs:documentation>
        </xs:annotation>
    <xs:sequence>
      <xs:element name="faultcode" type="xs:QName" />
      <xs:element name="faultstring" type="xs:string" />
      <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
      <xs:element name="detail" type="tns:detail" minOccurs="0" />      
    </xs:sequence>
  </xs:complexType>

the line:

<xs:element name="detail" type="tns:detail" minOccurs="0" />

with:

<xs:any minOccurs="0"/>

Will erlsom parse both correct and incorrect result?

lego12239 avatar Aug 22 '15 07:08 lego12239

That sounds like a good idea, give it a try.

On Sat, Aug 22, 2015 at 9:31 AM, Oleg [email protected] wrote:

If i'll replace here:

<xs:element name="Fault" type="tns:Fault" /> <xs:complexType name="Fault" final="extension" > xs:annotation xs:documentation Fault reporting structure /xs:documentation /xs:annotation xs:sequence <xs:element name="faultcode" type="xs:QName" /> <xs:element name="faultstring" type="xs:string" /> <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" /> <xs:element name="detail" type="tns:detail" minOccurs="0" /> /xs:sequence /xs:complexType

the line:

<xs:element name="detail" type="tns:detail" minOccurs="0" />

with:

<xs:any minOccurs="0"/>

Will erlsom parse both correct and incorrect result?

— Reply to this email directly or view it on GitHub https://github.com/willemdj/erlsom/issues/45#issuecomment-133648602.

willemdj avatar Aug 23 '15 07:08 willemdj

The results of my experiment:

with:

<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />

i get:

    {'soap:Fault',[],
                  {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                         "SOAP-ENV","soap"},
                  "error_request",undefined,undefined}}

with:

<xs:element name="detail" type="xs:string" minOccurs="0"/>

i get:

    {'soap:Fault',[],
                  {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                         "SOAP-ENV","soap"},
                  "error_request",undefined,"Invalid login/pass"}}

So, it seems i can't use any element in place of detail element or i do something wrong.

lego12239 avatar Aug 23 '15 12:08 lego12239

You are right: if you just need to be able to parse the answer without getting an error, using "any" works, but if you need the information in the element it doesn't. (It would be nice to make a change in erlsom so that "any" elements are included in the result in some generic form, that should not be so hard.)

What you might also try is to make the element of type "mixed" (mixed="true").

Good luck, Willem

On Sun, Aug 23, 2015 at 2:30 PM, Oleg [email protected] wrote:

The results of my experiment:

with:

<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />

i get:

{'soap:Fault',[],
              {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                     "SOAP-ENV","soap"},
              "error_request",undefined,undefined}}

with:

<xs:element name="detail" type="xs:string" minOccurs="0"/>

i get:

{'soap:Fault',[],
              {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                     "SOAP-ENV","soap"},
              "error_request",undefined,"Invalid login/pass"}}

So, it seems i can't use any element in place of detail element or i do something wrong.

— Reply to this email directly or view it on GitHub https://github.com/willemdj/erlsom/issues/45#issuecomment-133826367.

willemdj avatar Aug 25 '15 07:08 willemdj

So, with:

<xs:element name="detail" type="tns:detail" minOccurs="0" />

and with mixed="true" i get:

{ok,{'soap:Fault',[],
                  {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                         "SOAP-ENV","soap"},
                  "error_auth",undefined,
                  {'soap:detail',[],["Client not authorized"]}}}

and with:

<xs:element name="detail" type="xs:string" minOccurs="0" />

and without mixed="true" i get:

{ok,{'soap:Fault',[],
                  {qname,"http://schemas.xmlsoap.org/soap/envelope/","Server",
                         "SOAP-ENV","soap"},
                  "error_auth",undefined,"Client not authorized"}}

With mixed="true" the result looks more complicated, but it works!

lego12239 avatar Sep 01 '15 10:09 lego12239