mushaofeng / java-ws-discovery

Automatically exported from code.google.com/p/java-ws-discovery
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Need to publish service <hello> with <endpointReference> child nodes set #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Get/build code from svn
2. use WsDiscoveryFactory.createService to build service
3. use service.getEndpointReference() to get initial information
4. use endpointReference.set..[ReferenceParameters, PortType, ServiceName]
to set values

I seem to be able to set the values but they do not seem to go out on the
network. Currently I am using the 'Microsoft Network Monitor 3.3' tool to
look at the message packets.

From the sample service I can publish using the example gui I see what
schema is used. With that information I build a sample message that
validates, see below.

<?xml version="1.0" encoding="UTF-8"?>
<Hello xmlns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01
http://docs.oasis-open.org/ws-dd/discovery/1.1/os/wsdd-discovery-1.1-schema-os.x
sd">
 <wsa:EndpointReference>
   <wsa:Address>urn:uuid:be95c928-c065-443d-845a-44542ce9d2c9</wsa:Address>
     <wsa:ReferenceParameters>
       <anyThingCanGoHere>
         <hereIsSomething/>
         <hereIsAnotherThing/>
       </anyThingCanGoHere>
     </wsa:ReferenceParameters>
   </wsa:EndpointReference>
   <Types>service_Types</Types>
   <Scopes>service_Scopes</Scopes>
   <XAddrs>http://localhost:1234/service_Xaddrs</XAddrs>
   <MetadataVersion>1</MetadataVersion>
</Hello>

Looking at my valid sample message I would expect to be able to populate
<wsa:ReferenceParameters> since it validates with the same schema. I also
notices that .setPortType(portType) and .setServiceName(serviceName) do not
seem to work either.

I can see that they are set in the logs

Starting WS-Discovery server...
Publishing service:
    Address: urn:uuid:ea5ecdc9-b8af-4dd6-aea1-83076ce7bdce
    PortType: {service_PortType_namespace}service_PortType
    ServiceName.PortName: service_Name
    ServiceName.Value: {service_NameQ_namespace}service_NameQ
    Any:  Other: (null)
Types: {service_Types_namespace}service_Types
XAddrs: http://localhost:1234/service_Xaddrs
Scopes: service_Scopes

Thanks for you help on this potential issue

Original issue reported on code.google.com by nasgow...@gmail.com on 22 Jan 2010 at 8:47

GoogleCodeExporter commented 9 years ago
WS-Discovery 1.1 uses WS-Addressing 1.0 
(http://www.w3.org/TR/2006/REC-ws-addr-core-
20060509/#eprs). Thus it is no longer possible to set port type and service 
name directly through 
the endpointreference and the values are silently ignored (this should be 
fixed). You can use 
service.setPortTypes(), service.setScopes() and service.setXAddrs() instead, 
where service is an 
instance of WsDiscoveryService. 

If you configure the library to use the WS-Discovery draft-version which uses 
and older version of 
WS-Addressing, your example should work (see 
WsDiscoveryConstants.defaultNsDiscovery).

endpointReference.setReferenceParameters() should still be supported, though. I 
will investigate 
this further and get back to you shortly.

Original comment by mmag...@gmail.com on 25 Jan 2010 at 12:14

GoogleCodeExporter commented 9 years ago
Have you added JAXB annotations to all the objects that you pass as reference 
parameters?

You can test the XML-generating code without having to monitor the network.

Here's an example:

---
WsDiscoveryService service1 = WsDiscoveryFactory.createService(
                    new QName("namespace", "myTestService"), // Port type.
                    "http://myscope",                            // Scope.
                    "http://localhost:1234/myTestService");  // Invocation address (XAddrs)

service1.getEndpointReference().setMetadata(new SOAPOverUDPGenericAnyType());
// this will fail in JAXB:
service1.getEndpointReference().getMetadata().getAny().add("test");

WsDiscoveryS11SOAPMessage m = 
WsDiscoveryS11Utilities.createWsdSOAPMessageHello(service1);

System.out.println(m.toString(true, Charset.defaultCharset()));
---

The above example will fail with an exception, though - as the String-object 
passed to getAny().add() can't be handled directly by JAXB. If you remove the 
two lines that 
invoke getEndpointReference() you should see the XML.

Original comment by mmag...@gmail.com on 25 Jan 2010 at 1:01

GoogleCodeExporter commented 9 years ago

Original comment by mmag...@gmail.com on 3 Feb 2010 at 11:25