0

I have a problem with WSDL+XSD. My WSDL and XSD works fine by using Apache CXF:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://com.schema.goodsservice"
    xmlns="http://com.schema.goodsservice" 
    xmlns:tr="http://com.schema.goods"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <wsdl:types>
        <xsd:schema targetNamespace="http://com.schema.goodsservice">
            <xsd:import namespace="http://com.schema.goods"   schemaLocation="goods.xsd" />
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="goodsInput">
        <wsdl:part name="goods"   element="tr:goods"  />
    </wsdl:message>

    <wsdl:message name="goodsOutput">
        <wsdl:part name="status"  element="tr:status" />
    </wsdl:message>

    <wsdl:portType name="GoodsService">
        <wsdl:operation name="addgoods">
            <wsdl:input message="goodsInput" />
            <wsdl:output message="goodsOutput" />
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="GoodsServiceHTTPBinding" type="GoodsService">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
            <wsdl:operation name="addgoods">
                <wsdlsoap:operation soapAction="" />
                    <wsdl:input>
                        <wsdlsoap:body use="literal" />
                    </wsdl:input>
                <wsdl:output>
                    <wsdlsoap:body use="literal" />
                </wsdl:output>
            </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="GoodsServicePorts">
        <wsdl:port binding="GoodsServiceHTTPBinding" name="GoodsService">
            <wsdlsoap:address
                location="http://localhost:9084/goodsService/GoodsServicePorts" />
            </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

And XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema targetNamespace="http://com.schema.goods"
xmlns="http://com.schema.goods"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <!-- web service input types -->

    <xsd:element name="goods">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="parent_goods" type="parent_good" minOccurs="1" maxOccurs="unbounded" />
                <xsd:element name="child_goods" type="child_good" minOccurs="1" maxOccurs="unbounded" />
                <xsd:element name="login" type="xsd:string" minOccurs="1" maxOccurs="1" />
                <xsd:element name="password" type="xsd:string" minOccurs="1" maxOccurs="1" />
            </xsd:sequence> 
        </xsd:complexType>
    </xsd:element>

    <xsd:complexType name="parent_good">
        <xsd:sequence>
            <xsd:element name="age_beauty" type="xsd:string" minOccurs="0" maxOccurs="1" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="child_good">
        <xsd:sequence>
            <xsd:element name="age" type="xsd:integer" minOccurs="0" maxOccurs="1" />
        </xsd:sequence>
    </xsd:complexType>

    <!-- web service output types -->

    <xsd:element name="status">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="iserror" type="xsd:boolean" minOccurs="1" maxOccurs="1" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>

The task is to remove targetNamespace from the XSD file. How can i do it if targetNamespace of WSDL must be the same as XSD?

Thank you!

leppie
  • 115,091
  • 17
  • 196
  • 297
user1453201
  • 31
  • 1
  • 5
  • What are you trying to do - remove `targetNamespace` just to get rid of it or to make it the same as `targetNamespace` of WSDL? – Grzegorz Grzybek Jun 13 '12 at 10:02
  • i am trying to get rid of the (targetNamespace="blablabla") in the XSD file. – user1453201 Jun 13 '12 at 11:44
  • Don't do it - every schema file should have `targetNamespace`. – Grzegorz Grzybek Jun 13 '12 at 12:53
  • I haven't a choise. I can't change (not mine) XSD that definds types and validation, but I can change my WSDL. I need WSDL+XSD works, where XSD hasn't targetNamespace. I found article on the Oracle site that describes noNameSpase situation: [Handling No Namespace Schemas within your BPEL Processes](https://blogs.oracle.com/rammenon/entry/handling_no_namespace_schemas) but I still do not understand how to kill targetNameSpace from my XSD and my WSDL. – user1453201 Jun 13 '12 at 13:54
  • If you can't change the XSD, then don't do it. I'm still not sure why would you need unqualified elements and types to refer to in WSDL... But if you really must remove the `targetNamespace` from XSD then make a copy of it and use original one for validation and changed one as an import in WSDL. Maybe a liitle bit of XSLT may be needed somewhere. – Grzegorz Grzybek Jun 14 '12 at 04:50

0 Answers0