Dan Diephouse wrote:
Hi Polar,
On 4/2/07, Polar Humenn <[EMAIL PROTECTED]> wrote:
Hi Dan,
I was wondering if you could answer me a question. I'm writing a systest
for HTTP/S. Setting up servers always is a problem, because I never know
where things are coming from. So, maybe you can straighten me out where
things have to be.
I have placed a "greeting.wsdl" file in
test-classes/org/apache/cxf/transport/http/resources/ and use that in
the client side in new SOAPService(getResource("resources/greeting.wsdl,
serviceName).
However, setting up the servers I now keep getting something that isn't
working (i did an svn update). Now, my wsdl which has a target namespace
of "http://apace.org/hello_world/" cant seem to be found from the
JaxWsServerFactoryBean.createBindingInfo() call.
Any chance you can attach your test case and/or wsdl?
It appears to me that there is an elaborate namespace search going on
somewhere, but I haven't a clue what backdoor it's going through.
insight?
createBindingInfo attempts to look up a BindingFactory based on the
namespace of the binding in the wsdl. It then uses this to create a
Binding
object.
Also, something gets generated, but I don't know when, and merely that
this was working before, means I did something unconventional and forgot
about it, and/or that they are generated in a standard place I don't
know about and perhaps it was just conincidental and now changed. Could
this be in "testutils"?
I'm lost... are you wondering where your client is being generated?
You're not the only one! :)
I'm not really talking about the client. I'm talking about the
server/Endpoint side.
I though I had to pay attention to the annotations in the
GreeterImpl.java, which is also attached. My server is brought up by the
code in Server.java, also attached.
you added the wsdl to testutils, then yes thats where its being
generated.
Although you seem to have your wsdl in the http module itself?
Well, I do, because that's the only place I am under the impression I
can definitively find it in the code using a
getClass().getResource("resources/greeting.wsdl").
I imagine, if I have things with different namespaces, I might have to
get Maven to generate these things with a wsdl2java tool.
My question is, what are the locations are these things picked up at,
and how do I get any assurance that I'm not picking up somebody elses
definitions? Or that I'm overriding, stepping on, some other important
definitions?
I have a specific greeting.wsdl, because I only wanted to implement a
minimal "Greeter", and I have addressing information in the wsdl file,
which seems like the only way I can get the right thing configured with
a service.getPort(QName,class);
What were you doing before?
It just worked. I was mystified.
- Dan
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world"
xmlns:x1="http://apache.org/hello_world/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="http://apache.org/hello_world/types"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://apache.org/hello_world/types"
elementFormDefault="qualified">
<simpleType name="MyStringType">
<restriction base="string">
<maxLength value="30" />
</restriction>
</simpleType>
<element name="sayHi">
<complexType/>
</element>
<element name="sayHiResponse">
<complexType>
<sequence>
<element name="responseType" type="string"/>
</sequence>
</complexType>
</element>
<element name="greetMe">
<complexType>
<sequence>
<element name="requestType" type="tns:MyStringType"/>
</sequence>
</complexType>
</element>
<element name="greetMeResponse">
<complexType>
<sequence>
<element name="responseType" type="string"/>
</sequence>
</complexType>
</element>
<element name="pingMe">
<complexType/>
</element>
<element name="pingMeResponse">
<complexType/>
</element>
<element name="faultDetail">
<complexType>
<sequence>
<element name="minor" type="short"/>
<element name="major" type="short"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="sayHiRequest">
<wsdl:part element="x1:sayHi" name="in"/>
</wsdl:message>
<wsdl:message name="sayHiResponse">
<wsdl:part element="x1:sayHiResponse" name="out"/>
</wsdl:message>
<wsdl:message name="greetMeRequest">
<wsdl:part element="x1:greetMe" name="in"/>
</wsdl:message>
<wsdl:message name="greetMeResponse">
<wsdl:part element="x1:greetMeResponse" name="out"/>
</wsdl:message>
<wsdl:message name="pingMeRequest">
<wsdl:part name="in" element="x1:pingMe"/>
</wsdl:message>
<wsdl:message name="pingMeResponse">
<wsdl:part name="out" element="x1:pingMeResponse"/>
</wsdl:message>
<wsdl:message name="pingMeFault">
<wsdl:part name="faultDetail" element="x1:faultDetail"/>
</wsdl:message>
<wsdl:portType name="Greeter">
<wsdl:operation name="sayHi">
<wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
<wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
</wsdl:operation>
<wsdl:operation name="greetMe">
<wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
<wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
</wsdl:operation>
<wsdl:operation name="pingMe">
<wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
<wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
<wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHi">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHiRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHiResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="greetMe">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="greetMeRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="greetMeResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="pingMe">
<soap:operation style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="pingMeFault">
<soap:fault name="pingMeFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SOAPService">
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Mortimer">
<soap:address location="http://localhost:9000/Mortimer"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Tarpin">
<soap:address location="https://localhost:9003/Tarpin"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Rethwel">
<soap:address location="http://localhost:9004/Rethwel"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Gordy">
<soap:address location="https://localhost:9001/Gordy"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Bethal">
<soap:address location="https://localhost:9002/Bethal"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Hurlon">
<soap:address location="http://localhost:9006/Hurlon"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Poltim">
<soap:address location="https://localhost:9005/Poltim"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Abost">
<soap:address location="https://localhost:9007/Abost"/>
</wsdl:port>
<wsdl:port binding="tns:Greeter_SOAPBinding" name="Morpit">
<soap:address location="https://localhost:9008/Morpit"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.systest.http;
import java.util.logging.Logger;
import javax.jws.WebService;
import org.apache.hello_world.Greeter;
@WebService(serviceName = "SOAPService",
endpointInterface = "org.apache.hello_world.Greeter",
targetNamespace = "http://apache.org/hello_world")
public class GreeterImpl implements Greeter {
private static final Logger LOG =
Logger.getLogger(GreeterImpl.class.getPackage().getName());
private String myName;
public GreeterImpl() {
this("defaultGreeter");
}
public GreeterImpl(String name) {
myName = name;
}
public String greetMe(String me) {
LOG.info("Executing operation greetMe");
System.out.println("Executing operation greetMe");
System.out.println("Message received: " + me + "\n");
return "Hello " + me;
}
public String sayHi() {
LOG.info("Executing operation sayHi");
System.out.println("Executing operation sayHi\n");
return "Bonjour from " + myName;
}
public void pingMe() {
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.systest.http;
import java.net.URL;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
public class Server extends AbstractBusTestServerBase {
private String name;
private String address;
private URL configFileURL;
public Server(String[] args) throws Exception {
this(args[0], args[1], args[2]);
}
public Server(String n, String addr, String conf) throws Exception {
name = n;
address = addr;
configFileURL = new URL(conf);
System.out.println("Starting " + name + " Server at " + address);
}
protected void run() {
setBus(new SpringBusFactory().createBus(configFileURL, true));
Object implementor1 = new GreeterImpl(name);
// I don't know why this works.
EndpointImpl ep =
new EndpointImpl(
getBus(),
implementor1,
"http://apache.org/hello_world",
this.getClass().getResource("resources/greeting.wsdl"));
// How the hell do I know what the name of the
// http-destination is?
ep.publish(address);
}
public static void main(String[] args) {
try {
Server s = new Server(args[0], args[1], args[3]);
s.start();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
} finally {
System.out.println("done!");
}
}
}