2012-06-13 2 views
7

저는 WebService를 JAX-WS로 개발하고 있습니다. (저는 jaxws-maven-plugin에서 wsimport goal을 사용하고 있습니다). XSD 스키마를 가져 오는 WSDL을 작성했습니다.xsd 스키마가 wsdl로 표시되지 않았습니다.

WEB-INF/wsdl/service.wsdl 
WEB-INF/wsdl/service.xsd 

또한 웹 서비스 클래스를 생성하고 엔드 포인트를 생성했습니다. 지금까지 모든 것이 훌륭했습니다. Tomcat 7에서 서비스를 실행했을 때 모든 것이 정상입니다. 나는에서 내 브라우저에서 WSDL에 액세스 할 수 있습니다

http://localhost:8080/webService/servlet-url?wsdl 

그러나 나는 XSD 스키마에 액세스 할 수 없습니다. 클래스 WSDL 및 XSD의 생성 중에

물론
<xsd:schema> 
<xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="service.xsd"/> 
</xsd:schema> 

는 로컬 경로에 있지만 나는 웹 서비스가 실행 중일 때이를 원격으로 액세스하려면, : 문제는이 WSDL이다. schemaLocation은 "http : // localhost : 8080/webService/servlet-url? xsd = 1"과 같아야합니다.

<xsd:schema> 
    <xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="http://localhost:8080/webService/servlet-url?wsdl&resource=service.xsd"/> 
    </xsd:schema> 

로컬 호스트 : 8080/웹 서비스/서블릿 WSDL이 날 수 있습니다 :? 등등

wsdl:definitions targetNamespace="http://ws.serv.com/Service/1.0" name="emuiaService">   
<wsdl:types> 
    <xsd:schema> 
     <xsd:import namespace="http://ws.serv.com/Service/domain/1.0" schemaLocation="schema.xsd"/> 
    </xsd:schema> 
</wsdl:types> 
<wsdl:message name="halloMsg"> 
    <wsdl:part name="parameters" element="dom:halloRequest"/> 
</wsdl:message> 
<wsdl:message name="halloResponseMsg"> 
    <wsdl:part name="return" element="dom:halloResponse"/> 
</wsdl:message> 

와 ...

답변

4

나는 이것이 거의 그렇게 어려운 문제라고 믿을 수 없다!

나는 정확하게이 문제에 대한 해결책을 찾기 위해 미친 듯이 검거하고있다! 그렇다면 나는 스스로 해결할 해결책을 찾기 위해 열심히 노력해 왔습니다. 디버거 - java-6-openjdk의 기본 javax.xml.ws.spi.Provider 구현 (웹 서비스 게시에 사용하는 javax.xml.ws.Endpoint 객체를 만드는 JRE의 "factory")을 통해 마지막으로 적어도 나의 현재 JRE, 적어도, 자바 SE에서 작동하는 솔루션 공예 나에게 도움이되는 몇 가지를 배웠다 :이 솔루션은 자바 EE에서 사용할 수

java version "1.6.0_33" 
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-1ubuntu0.12.04) 
OpenJDK Server VM (build 23.25-b01, mixed mode) 

여부를 모르겠어요 아직. 여기

내가 그것을 해결하는 방법입니다

package myservice; 

import java.io.IOException; 
import java.io.InputStream; 
import java.net.URL; 
import java.util.Arrays; 
import javax.xml.transform.Source; 
import javax.xml.transform.stream.StreamSource; 
import javax.xml.ws.Endpoint; 

public class App 
{ 
    private static final String MY_SERVICE_XSD = "/wsdl/MyService.xsd"; 

    public static void main(String[] args) 
    { 
     Endpoint ep = Endpoint.create(new MyEndpointImpl()); 

     ep.setMetadata(Arrays.asList(sourceFromResource(MY_SERVICE_XSD))); 

     ep.publish("http://localhost:8080/svc/hello"); 
    } 

    private static Source sourceFromResource(String name) { 
     URL resource = App.class.getResource(name); 
     String systemId = resource.toExternalForm(); 
     InputStream inputStream; 
     try { 
      inputStream = resource.openStream(); 
     } catch (IOException e) { 
      throw new RuntimeException("Failed to create InputStream from resource \""+ name +"\"", e); 
     } 
     return new StreamSource(inputStream, systemId); 
    } 
} 

결정적인 것은 내가 처음 사용 방법 엔드 포인트 번호가 만드는 것이 인 게시되지 않은 엔드 포인트를 얻기 위해 (엔드 포인트하지 # 게시). 그런 다음 XSD 파일을 (아직 공개되지 않은) 끝점 (코드 "ep.setMetaData (...)")에 "메타 데이터"로 추가합니다. 다음 끝점 (코드 "ep.publish (...)")을 게시합니다. 내가 http://localhost:8080/svc/hello?wsdl에 액세스 할 때

지금 내가 얻을 :

<definitions targetNamespace="http://somewhere.net/my/namespace" name="MyService"> 
     <types> 
      <xsd:schema> 
       <xsd:import namespace="http://somewhere.net/my/namespace" 
          schemaLocation="http://localhost:8080/svc/hello?xsd=1"/> 
      </xsd:schema> 
     </types> 
        ... 
    </definitions> 

내 XSD 파일이 http://localhost:8080/svc/hello?xsd=1에서 사용할 수 있습니다! 디스크에 내 MyService.wsdl 파일이 여전히 포함

참고 :

  <xsd:schema> 
       <xsd:import namespace="http://somewhere.net/my/namespace" 
          schemaLocation="MyService.xsd"></xsd:import> 
      </xsd:schema> 
+0

나는 내가 한 일을 기억하지 못한다. 아마 계약을 마쳤을 지 모르지만 그것을 해결해 주셔서 감사합니다. 언젠가 누군가를 돕기를 바랍니다.) – bemol

0

같이 schould 브라우저 수입에 제시된 WSDL에서

좋아, 여기있다. WSDL 파일에

중요 XMLNS 태그있는이 작은 조각에이

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<wsdl:definitions 
     targetNamespace="http://service.wsr.company.com/" 
     name="webServiceExample" 
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:tns="http://servicio.wsr.baz.com/" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> 

같은 것을 modificate합니다. 스키마 XSD 배포에 사용됩니다. 당신이 아래 그 태그에

<wsdl:types> 
    <xs:schema 
     xmlns:tns="http://service.wsr.company.com/" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     targetNamespace="http://service.wsr.company.com/" version="1.0"> 

     ... 

    </xs:schema> 
</wsdl:types> 

다음 우리는 당신의 방법 이름을 표시입니다

<wsdl:message name="your_method_name"> 
     <wsdl:part name="parameters" element="tns:your_method_name"/> 
    </wsdl:message> 
    <wsdl:message name="your_method_nameResponse"> 
     <wsdl:part name="parameters" element="tns:your_method_nameResponse"/> 
    </wsdl:message> 

그 위의 태그를 계속하면 service.xsd 파일에 무엇을 얻거나 http://localhost:8080/webService/servlet-url?xsd=1에서 보여주지. 다음

<wsdl:portType name="webServiceExample"> 
      <wsdl:operation name="your_method_name"> 
      <wsdl:input message="tns:your_method_name"/> 
       <wsdl:output message="tns:your_method_nameResponse"/> 
      </wsdl:operation> 
    </wsdl:portType> 

위의 타르는 작업을위한 것입니다. 계속

<wsdl:binding name="webServiceExamplePortBinding" type="tns:webServiceExample"> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     <wsdl:operation name="your_method_name"> 
      <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="webServiceExample"> 
    <wsdl:port name="webServiceExamplePort" binding="tns:webServiceExamplePortBinding"> 
     <soap:address location="REPLACE_WITH_ACTUAL_URL"/> 
</wsdl:port> 
마침내 완성 : 당신이 태그에 의해 현재의 태그를 변경해야

<wsdl:...></wsdl:...>

여러분은 그것을 공개하고 재미있게 보냅니다. XSD 스키마는 WSDL에서 제공됩니다.

도와 드리겠습니다. 차오.

+0

불행하게도 작동하지 않았다. 여전히 스키마 xsd는 http를 통해 제공되지 않습니다. – bemol

+0

WSDL 파일을 어떻게 보이는지 보여주십시오. :) – hekomobile

관련 문제