JBuilder 8 EE 에 있는 튜토리얼을 보고 그대로 따라하면서 간단한 웹서비스를 만들어서 돌려봤습니다. AXIS와 톰캣 4.0을 사용했습니다. 모두 자동 생성된 코드니까 특별히 제가 실수한 부분은 없을것 같은데 실행하니까
unit.framework.AssertionFailedError: Remote Exception caught: (401)Unauthorized
at exportbean5.generated.Bean1ServiceTestCase.test2Bean1GetSample(Bean1ServiceTestCase.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at com.borland.jbuilder.unittest.JBTestRunner.run(JBTestRunner.java:206)
at com.borland.jbuilder.unittest.JBTestRunner.initiateTest(JBTestRunner.java:248)
at com.borland.jbuilder.unittest.JBTestRunner.main(JBTestRunner.java:554)
와 같은 예외가 발생합니다. 예외가 발생한 Bean1ServiceTestCase.java:51 부분은 value = binding.getSample();를 하다가 발생했습니다. getSample()이라는 메쏘드가 웹서비스로 노출시킨 함수입니다. Unauthorized 라길래 보안 문제인듯 해서 tomcat 4.0 디렉토리에 있는 tomcat-users.xml 파일에 "", "" 라는 사용자를 추가해보기도 하고 stub 자바 파일에서 org.apache.axis.client.Call.setUsername("tomcat"), setPassword("tomcat") 라고 tomcat-users.xml 파일에 있는 사용자를 런타임에 설정해보기도 했습니다. 그런데 다 소용이 없네요. 혹시 wsdl 파일에 그런 정보가 있나하고 봤더니 거긴 보안에 관한 내용이 없더군요. 어떤 문제인지 모르겠네요. 오늘 웹서비스를 처음 해본거라 제가 간단한거를 놓친 것 같은데 도움 부탁드립니다.
참고로 wsdl 파일은 다음과 같습니다.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="
http://exportbean5" xmlns="
http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="
http://xml.apache.org/xml-soap" xmlns:impl="
http://exportbean5-impl" xmlns:intf="
http://exportbean5" 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>
<schema targetNamespace="
http://exportbean5" xmlns="
http://www.w3.org/2001/XMLSchema">
<import namespace="
http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_xsd_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
<element name="ArrayOf_xsd_string" nillable="true" type="intf:ArrayOf_xsd_string"/>
</schema>
</wsdl:types>
<wsdl:message name="getSampleResponse">
<wsdl:part name="getSampleReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getSampleRequest">
</wsdl:message>
<wsdl:message name="setSampleRequest">
<wsdl:part name="sample" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="setSampleResponse">
</wsdl:message>
<wsdl:message name="mainResponse">
</wsdl:message>
<wsdl:message name="mainRequest">
<wsdl:part name="args" type="intf:ArrayOf_xsd_string"/>
</wsdl:message>
<wsdl:portType name="Bean1PortType">
<wsdl:operation name="main" parameterOrder="args">
<wsdl:input message="intf:mainRequest" name="mainRequest"/>
<wsdl:output message="intf:mainResponse" name="mainResponse"/>
</wsdl:operation>
<wsdl:operation name="getSample">
<wsdl:input message="intf:getSampleRequest" name="getSampleRequest"/>
<wsdl:output message="intf:getSampleResponse" name="getSampleResponse"/>
</wsdl:operation>
<wsdl:operation name="setSample" parameterOrder="sample">
<wsdl:input message="intf:setSampleRequest" name="setSampleRequest"/>
<wsdl:output message="intf:setSampleResponse" name="setSampleResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Bean1SoapBinding" type="intf:Bean1PortType">
<wsdlsoap:binding style="rpc" transport="
http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="main">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="mainRequest">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:input>
<wsdl:output name="mainResponse">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSample">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getSampleRequest">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:input>
<wsdl:output name="getSampleResponse">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="setSample">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="setSampleRequest">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:input>
<wsdl:output name="setSampleResponse">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://exportbean5" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Bean1Service">
<wsdl:port binding="intf:Bean1SoapBinding" name="Bean1">
<wsdlsoap:address location="
http://localhost:8080/axis/services/Bean1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>