• Post Reply Bookmark Topic Watch Topic
  • New Topic

Modify the wsdl in memory and use it in Service.create(..)

 
lucky Behl
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JAX-WS and it's WSDL has following line:
<wsp:PolicyReference URI="policy:Xyz-UserNameToken-Plain.xml"/>

I had to manually commented above line and put modified WSDL in classpath

My JAX-WS Client code is like:

URL wsdlLocation = new URL("http://172.31.110.180:7403/WSServiceImpl/WSService?wsdl");
QName serviceName = new QName("http://ws2.service.abc.xyz.com/", "WSService");

Service s = Service.create(this.getClass().getResource("WSService.wsdl"), serviceName);
=========================================================================================
WSService wsService = s.getPort(WSService.class);

As you see above underlined line reads WSService wsdl file.

I don't want to read manually pre-edited WSDL
I rather would want to READ WSDL URL on the fly and edit it (by commenting <wsp:PolicyReference ....)

I guess its doable by Reading the wsdl using a HttpURLConnection object, modify the wsdl in memory and use it in Service.create(....)

From HttpURLConnection, i could read WSLD on the fly and create a String form of WSDL which will not have

But the question is how do i convert this string into URL object in runtime?? Because URL is expected in:: Service.create(URl url, QName qName)

Can somebody please provide sample code??

Regards,
 
Nate Astle
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the url connection takes a string on the constructor so you can change
Service.create(URl url, QName qName)
and for URL you can do

new URL("sitehost");
 
lucky Behl
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Thanks for quick reply

After removing <wsp:PolicyRef.......> from original WSLD, my String looks like this:

<?xml version='1.0' encoding='UTF-8'?>..
<definitions xmlns:wssutil="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ..................................>
<wsp:UsingPolicy wssutil:Required="true"/>
<wsp:Policy wssutil:Id="Xyz-UserNameToken-Plain">
<ns1:SupportingTokens xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512">
<wsp:Policy>
<ns1:UsernameToken ns1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<ns1:WssUsernameToken10/>
</wsp:Policy>
</ns1:UsernameToken>
</wsp:Policy>
</ns1:SupportingTokens>
</wsp:Policy>
<types>
<xsd:schema>
<xsd:import namespace="http://ws2.service.xyz.abc.com/" schemaLocation="http://host:port/WSServiceImpl/WSService?xsd=1"/>
</xsd:schema>
</types>
<message name="clear">
<part name="parameters" element="tns:clear"/>
</message>
..
..
..
..
</port>
</service>
</definitions>

With this kind of String, i can't make URL object because to make URL object out of String we need "HTTP" in it

Is there any other Solution??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!