Frage

I'm trying to create a webservice using the New -> Web Service from WSDL in Netbeans 7.1.2.

I went ahead and created a WSDL using XML spy. Here is the basic WSDL that I've created:

<wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:wsp="http://www.w3.org/ns/ws-policy" 
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" 
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tns="http://planningservice.ohs.com/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://docs.oasis-open.org/wsn/t-1" xmlns:ns1="http://www.isotc211.org/2005/gco" xmlns:ns2="http://www.isotc211.org/2005/gmd" xmlns:ns3="http://www.isotc211.org/2005/gsr" xmlns:ns4="http://www.isotc211.org/2005/gss" xmlns:ns5="http://www.isotc211.org/2005/gts" xmlns:ns6="http://www.opengis.net/gml/3.2" xmlns:ns7="http://www.opengis.net/ows/1.1" xmlns:ns8="http://www.opengis.net/sps/2.0" xmlns:ns9="http://www.opengis.net/swe/2.0" xmlns:ns10="http://www.opengis.net/swes/2.0" xmlns:ns11="http://www.w3.org/2005/08/addressing" name="PlanningService" targetNamespace="http://planningservice.ohs.com/">
<wsdl:import namespace="http://www.opengis.net/sps/2.0" location="http://schemas.opengis.net/sps/2.0/spsGetFeasibility.xsd"/>
<wsdl:types>
    <xsd:schema>
        <xsd:import namespace="http://ps.ca"/>
    </xsd:schema>
</wsdl:types>
<wsdl:message name="GetFeasibility">
    <wsdl:part name="parameters" type="ns8:GetFeasibilityType"/>
</wsdl:message>
<wsdl:message name="GetFeasibilityResponse">
    <wsdl:part name="parameters" type="ns8:GetFeasibilityResponseType"/>
</wsdl:message>
<wsdl:portType name="PlanningService">
    <wsdl:operation name="GetFeasibility">
        <wsdl:input message="tns:GetFeasibility" wsam:Action="http://planningservice.ohs.com/PlanningService/getFeasibility"/>
        <wsdl:output message="tns:GetFeasibilityResponse" wsam:Action="http://planningservice.ohs.com/PlanningService/getFeasibilityResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PlanningSerivcePortBinding" type="tns:PlanningService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetFeasibility">
        <soap:operation soapAction="' '"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="PlanningSerivce">
    <wsdl:port name="PlanningService" binding="tns:PlanningSerivcePortBinding">
        <soap:address location="http://localhost:8080/PlanningService/"/>
    </wsdl:port>
</wsdl:service>

When I try using the above I the 'New Web Service From WSDL' wizard says "There is no service in specified WSDL file."

If I don't specify the location attribute, like so:

<wsdl:service name="PlanningSerivce">
    <wsdl:port name="PlanningService" binding="tns:PlanningSerivcePortBinding">
        <soap:address/>
    </wsdl:port>
</wsdl:service>

I don't have that notification but during the creation of the Web Service I get an error that says the attribute is missing.

So my question is what do I put in the location attribute to get Netbeans to recognize that there is a service defined, given that it isn't deployed anywhere!

Thanks all!

~D

War es hilfreich?

Lösung

The WSDL document as provided is not entirely valid.

The first issue is the declaration of the document style but the message declaration in the rpc style. Rpc uses message parts defined in terms of 'type's. Document uses message parts defined in terms of 'element's. I looked over the XSD imported into the WSDL and found the 'GetFeasibility' and 'GetFeasibilityResponse' elements defined there. So, changing the wsdl:message nodes to

  <wsdl:message name="GetFeasibility">
    <wsdl:part name="parameters" element="ns8:GetFeasibility"/>
  </wsdl:message>
  <wsdl:message name="GetFeasibilityResponse">
    <wsdl:part name="parameters" element="ns8:GetFeasibilityResponse"/>
  </wsdl:message>

helps by making the message definitions consistent with the document style service. There is a nice writeup at http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ about wsdl construction w.r.t. declared styles.

The next issue is the schema import. There are special restrictions around the wsdl:import statement. In general, the proper place to pull in schemas is the wsdl:types section. If you use something like

  <wsdl:types>
    <xsd:schema>
      <xsd:import namespace="http://www.opengis.net/sps/2.0" 
      schemaLocation="http://schemas.opengis.net/sps/2.0/spsGetFeasibility.xsd"/>
      <xsd:import namespace="http://ps.ca"/>
    </xsd:schema>
  </wsdl:types>

(not sure of the value of the ps.ca import), the relevant types are available for the wsdl import machinery. A writeup of wsdl importing is at http://scn.sap.com/people/kevin.liu/blog/2004/06/28/a-note-on-wsdl-and-xsd-imports

Once these modifications were made, wsimport still saw an error in the form of a name collision in the supporting schemas at opengis.net, but hopefully this gives you enough to move our project along a bit and you can focus on the name collision rather than fighting the wsdl construction.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top