cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a new alfresco WS?

pavel
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to create a new alfresco web service, I followed http://forums.alfresco.com/en/viewtopic.php?f=27&t=11113 , and successfully created a simple WS:
so the steps below, after creating a new java class and generating a wsdl and wsdd:

1. wsdl copied to \alfresco\wsdl;
2. wsdd content copied to server-config.wsdd;
3. java library copied to \lib\.

And I'm able to access the newly created WS.
The next step would be to develop the new service a bit more, so that it can work with alfresco repository etc.

Any ideas how can I access alfresco from the java class + deploy this to alfresco?

Thanks,
Pavel
3 REPLIES 3

pmonks
Star Contributor
Star Contributor
To access the Alfresco APIs you would normally inject (via Spring) the ServiceRegistry bean.  This may be difficult to do for custom Web Service classes, so you can also use the ApplicationContextHelper (http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/util/ApplicationContextHelper.htm...) to statically retrieve it, if need be (note that this isn't as elegant as using dependency injection, so try to use that if you can).

As for packaging extensions and deploying them to Alfresco, the recommended approach is to use an AMP file (http://wiki.alfresco.com/wiki/AMP_Files), in conjunction with the Module Managament Tool (http://wiki.alfresco.com/wiki/Module_Management_Tool).

Cheers,
Peter

pavel
Champ in-the-making
Champ in-the-making
Thanks a lot, I'll try that

gurusanka
Champ in-the-making
Champ in-the-making
Hi,
Though I have worked on Web Services, I am new to Alfresco. I was trying to create and deploy a "Hello World" Web Service in Alfresco, but i couldn't succeed. I have followed the same old instructions given in the following link except the fact that I have used "Top Down Approach" for creating a web service (generate code from WSDL)
http://forums.alfresco.com/en/viewtopic.php?f=27&t=11113
1. Created a sample WSDL using eclipse
2. Generated the code for the WSDL using axis
3. Copied the content server-config.wsdd  (generated one) in the server-config.wsdd of the alfresco.
4. Copied the WSDL in \wsdl folder
5. Copied the jar file in \lib folder
6. Restarted the server

After that, when i try to access the service (http://localhost:8080/alfresco/NewWSDLFile/NewOperation) I am getting Resource Not Found error ie 404. I feel some configuration is missing in the process.

Can anybody help me out please?

server-config.wsdd entry

<service name="NewWSDLFile" provider="java:RPC" style="document" use="literal">
    <wsdlFile>/wsdl/NewWSDLFile.wsdl</wsdlFile>
     <operation name="newOperation" qname="NewOperation" soapAction="http://localhost:8080/NewWSDLFile/NewOperation">
      <parameter mode="inout" name="parameters" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema'/>
     </operation>
     <parameter name="wsdlServicePort" value="NewWSDLFileSOAP"/>
     <parameter name="className" value="NewWSDLFile.ws.NewWSDLFileSOAPImpl"/>
     <parameter name="typeMappingVersion" value="1.2"/>
     <parameter name="allowedMethods" value="newOperation"/>
     <parameter name="wsdlServiceElement" value="NewWSDLFile"/>
     <parameter name="wsdlTargetNamespace" value="http://localhost:8080/alfresco/NewWSDLFile/NewOperation/'/>
     <parameter name="wsdlPortType" value="NewWSDLFile"/>
     <parameter name="scope" value="Session"/>
     <parameter name="schemaUnqualified" value="http://localhost:8080/alfresco/NewWSDLFile/NewOperation/'/>
    </service>



WSDL file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://example.org/NewWSDLFile/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NewWSDLFile" targetNamespace="http://example.org/NewWSDLFile/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://example.org/NewWSDLFile/">
      <xsd:element name="NewOperation">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="in" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="NewOperationResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="out" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="NewOperationRequest">
    <wsdlSmiley Tongueart name="parameters" type="xsd:string"/>
  </wsdl:message>
  <wsdl:message name="NewOperationResponse">
    <wsdlSmiley Tongueart name="parameters" type="xsd:string"/>
  </wsdl:message>
  <wsdlSmiley TongueortType name="NewWSDLFile">
    <wsdlSmiley Surprisedperation name="NewOperation">
      <wsdl:input message="tns:NewOperationRequest"/>
      <wsdlSmiley Surprisedutput message="tns:NewOperationResponse"/>
    </wsdlSmiley Surprisedperation>
  </wsdlSmiley TongueortType>
  <wsdl:binding name="NewWSDLFileSOAP" type="tns:NewWSDLFile">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http'/>
    <wsdlSmiley Surprisedperation name="NewOperation">
      <soapSmiley Surprisedperation soapAction="http://localhost:8080/alfresco/NewWSDLFile/NewOperation'/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdlSmiley Surprisedutput>
        <soap:body use="literal"/>
      </wsdlSmiley Surprisedutput>
    </wsdlSmiley Surprisedperation>
  </wsdl:binding>
  <wsdl:service name="NewWSDLFile">
    <wsdlSmiley Tongueort binding="tns:NewWSDLFileSOAP" name="NewWSDLFileSOAP">
      <soap:address location="http://localhost:8080/alfresco/NewWSDLFile/NewOperation'/>
    </wsdlSmiley Tongueort>
  </wsdl:service>
</wsdl:definitions>


Thanks in Advace
Guru