validating SOAP-Request with a SOAPHandler

Rubén

I'm trying to validate a SOAP-Request against the Schemas defined in the WSDL. I'm using a SOAPHandler with a SOAP-Handler-Chain. It works the only problem is that when I'm validating the request, I get this error message:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'v1:latitude'. One of '{"http://schemas.domain.com/wsdl/fuelprice/v1/model":latitude}' is expected.

The WSDL looks like this:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      mlns:http="http://schemas.xmlsoap.org/wsdl/http/"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:tns="http://schemas.domain.com/wsdl/fuelprice/v1"
      xmlns:model="http://schemas.domain.com/wsdl/fuelprice/v1/model"
      xmlns:exception="http://schemas.domain.com/wsdl/fuelprice/v1/exception"
      targetNamespace="http://schemas.domain.com/wsdl/fuelprice/v1">
<wsdl:types>
    <xsi:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.domain.com/wsdl/fuelprice/v1" elementFormDefault="qualified">
        <xsi:import namespace="http://schemas.domain.com/wsdl/fuelprice/v1/model" schemaLocation="common.xsd"/>
        <xsi:import namespace="http://schemas.domain.com/wsdl/fuelprice/v1/exception" schemaLocation="exception.xsd"/>
        <xsi:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>
        <xsi:element name="GetAreaFuelStationsRequest">
            <xsi:complexType>
                <xsi:sequence>
                    <xsi:element name="area" type="model:Area"/>
                </xsi:sequence>
                <xsi:attribute name="provider" type="xsi:string" use="optional"/>
                <xsi:attribute name="prices" type="xsi:boolean" use="required"/>
            </xsi:complexType>
        </xsi:element>

The XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xsi:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema" xmlns:model="http://schemas.domain.com/wsdl/fuelprice/v1/model" targetNamespace="http://schemas.domain.com/wsdl/fuelprice/v1/model" elementFormDefault="qualified">
<xsi:complexType name="FuelStation">
    <xsi:complexType name="Area">
        <xsi:sequence>
            <xsi:element name="center" type="model:GeoLocation"/>
            <xsi:element name="radius" type="xsi:float"/>
        </xsi:sequence>
    </xsi:complexType>
    <xsi:complexType name="GeoLocation">
        <xsi:sequence>
            <xsi:element name="latitude" type="xsi:double"/>
            <xsi:element name="longitude" type="xsi:double"/>
        </xsi:sequence>
        <xsi:attribute name="ellipsoid" type="xsi:string" use="required"/>
    </xsi:complexType>

The source code fragment:

    try {
        context.getMessage().getSOAPPart().getEnvelope();
        schemas = getSchemas(new URL(wsdlURI.toString().concat(wsdl)));
        schema = factory.newSchema(schemas);
        validator = schema.newValidator();
        validator.validate(new DOMSource(xml));
    }

A request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://schemas.domain.com/wsdl/fuelprice/v1" xmlns:mod="http://schemas.domain.com/wsdl/fuelprice/v1/model">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:GetAreaFuelStationsRequest provider="ep1" prices="true">
         <v1:area>
            <mod:center ellipsoid="false">
                 <v1:latitude>49.8385</v1:latitude>
                 <v1:longitude>8.5014</v1:longitude>
            </mod:center>
            <mod:radius>10</mod:radius>
         </v1:area>
      </v1:GetAreaFuelStationsRequest>
   </soapenv:Body>
</soapenv:Envelope>

Can anybody see what is wrong here? I have set

elementFormDefault="qualified"

but it did not work.

Rubén

What I did to get it working:

  1. I imported into the wsdl the soap/envelope schema
  2. I got the request body element and created a document from it as the document root
  3. I added to the body-element the soap/envelope namespace

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the request of a SOAP response using SOAPHandler

From Dev

Change namespaceURI in request with SOAPHandler

From Dev

Not able to log complete SOAP message in SOAPHandler

From Dev

How to use Mule schema-validation-filter for validating SOAP Request

From Dev

How to use Mule schema-validation-filter for validating SOAP Request

From Dev

How to fix soapenv:Envelope issue in XSD schema while validating with SOAP request/response

From Dev

How to fix soapenv:Envelope issue in XSD schema while validating with SOAP request/response

From Dev

Validating a part of request in DataPower

From Dev

Validating a part of request in DataPower

From Dev

Validating array request in Laravel

From Java

JDK 11: java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler

From Dev

JDK 11: java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler

From Dev

SOAPHandler handleFault

From Dev

Validating Request Content-Type

From Dev

Validating request parameter before controller

From Dev

Validating request parameter before controller

From Dev

Validating Request Schema With Fastify and AJV

From Dev

SOAP: HTTP Bad Request

From Dev

SOAP request in R

From Dev

How to make the SOAP request

From Dev

SOAP request to WebService with java

From Dev

SOAP request with 500 error

From Dev

Adding SOAP Header to request

From Dev

Change SOAP request format

From Dev

Redirect Soap request with apache

From Dev

SOAP request going to localhost

From Dev

XPATH search in SOAP request

From Dev

PHP SOAP Request Issues

From Dev

CXF Soap request/response