Apache CXF 3.1.8 Codegen-cxf-plugin disable validation
I'm using Codegen-cxf-plugin in my ejb project to work as soap client.
When I try to initialize service:
private static WsProviderPortType lkService = null;
WsProviderService lk = new WsProviderService(new URL(AppConfig.getConfig().getProperty("lk.service")));
lkService = lk.getWsProviderPort();
Cxf download wsdl and xsd and check it. I want to turn this validation off. How can I do it?
Is there a way to do this with annotations?
Here is generated with wsdl class:
#WebServiceClient(name = "WsProviderService",
wsdlLocation = "file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl",
targetNamespace = "http://south.rt.ru/WsProvider/")
public class WsProviderService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://south.rt.ru/WsProvider/", "WsProviderService");
public final static QName WsProviderPort = new QName("http://south.rt.ru/WsProvider/", "WsProviderPort");
static {
URL url = null;
try {
url = new URL("file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(WsProviderService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl");
}
WSDL_LOCATION = url;
}
public WsProviderService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public WsProviderService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public WsProviderService() {
super(WSDL_LOCATION, SERVICE);
}
public WsProviderService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public WsProviderService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public WsProviderService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
Here is my part of my wsdl:
......
<wsdl:portType name="WsProviderPortType">
<wsdl:operation name="UpdateStatus">
<wsdl:input name="UpdateStatusRequest" message="tns:UpdateStatusRequest">
</wsdl:input>
<wsdl:output name="UpdateStatusResponse" message="tns:UpdateStatusResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="canCharge">
<wsdl:input name="canChargeRequest" message="tns:canChargeRequest"/>
<wsdl:output name="canChargeResponse" message="tns:canChargeResponse"/>
</wsdl:operation>
<wsdl:operation name="getOrder">
<wsdl:input name="getOrderRequest" message="tns:getOrderRequest">
</wsdl:input>
<wsdl:output name="getOrderResponse" message="tns:getOrderResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAvailableSIMCardsList">
<wsdl:input name="getAvailableSIMCardsListRequest" message="tns:getAvailableSIMCardsListRequest">
</wsdl:input>
<wsdl:output name="getAvailableSIMCardsListResponse" message="tns:getAvailableSIMCardsListResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="updateOrderStatus">
<wsdl:input name="updateOrderStatusRequest" message="tns:updateOrderStatusRequest">
</wsdl:input>
<wsdl:output name="updateOrderStatusResponse" message="tns:updateOrderStatusResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createOrderB2B">
<wsdl:input name="createOrderB2BRequest" message="tns:createOrderB2BRequest">
</wsdl:input>
<wsdl:output name="createOrderB2BResponse" message="tns:createOrderB2BResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchOrder">
<wsdl:input name="searchOrderRequest" message="tns:searchOrderRequest">
</wsdl:input>
<wsdl:output name="searchOrderResponse" message="tns:searchOrderResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UpdateStatusLastMileCMS">
<wsdl:input name="UpdateStatusLastMileCMSRequest" message="tns:UpdateStatusLastMileCMSRequest">
</wsdl:input>
<wsdl:output name="UpdateStatusLastMileCMSResponse" message="tns:UpdateStatusLastMileCMSResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WsProviderServiceSoapBinding" type="tns:WsProviderPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="UpdateStatus">
<wsdl:input name="UpdateStatusRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="UpdateStatusResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="canCharge">
<wsdl:input name="canChargeRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="canChargeResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOrder">
<wsdl:input name="getOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAvailableSIMCardsList">
<wsdl:input name="getAvailableSIMCardsListRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAvailableSIMCardsListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="updateOrderStatus">
<wsdl:input name="updateOrderStatusRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="updateOrderStatusResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createOrderB2B">
<wsdl:input name="createOrderB2BRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createOrderB2BResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="searchOrder">
<wsdl:input name="searchOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="searchOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UpdateStatusLastMileCMS">
<wsdl:input name="UpdateStatusLastMileCMSRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="UpdateStatusLastMileCMSResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WsProviderService">
<wsdl:port name="WsProviderPort" binding="tns:WsProviderServiceSoapBinding">
<soap:address location="http://lkdevel2.south.rt.ru/wsp/soap/wsprovider/lk_srv"/>
</wsdl:port>
</wsdl:service>
Here is my pom:
</dependencies>
<properties>
<cxf-version>3.1.8</cxf-version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>test</id>
<dependencies>
<dependency>
<groupId>ru.rt.mdm</groupId>
<artifactId>fw_ejb</artifactId>
<version>${mdm.fw.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.8</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
${basedir}/src/main/resources/wsdl/test/newordernotificationb2b_client_ep.wsdl
</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>http://result.general.rt.ru=ru.rt.general.result.mrf.center
</extraarg>
<extraarg>-p</extraarg>
<extraarg>
http://problem.result.general.rt.ru=ru.rt.general.result.mrf.center.problem
</extraarg>
</extraargs>
</wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/test/wsAttachment.wsdl</wsdl>
</wsdlOption>-->
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<cxf-version>3.1.8</cxf-version>
<mdm.fw.version>3.0</mdm.fw.version>
<mdm.domain.jar>domain-3.0.jar</mdm.domain.jar>
<service.login>testLogin</service.login>
<service.password>testPass</service.password>
</properties>
</profile>
</profiles>
The one of the solution was to add BindingProvider in the Service class and set endpoint settings in getRequestContext() method :
BindingProvider bp = (BindingProvider) lkService;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AppConfig.getConfig().getProperty("lk.service"));
Related
I created a SOAP service in .Net standard using Visual Studio 2019, see code below
The service has a HelloWorld function which correctly returns "Hello World" when queried using Postman (see query below)
I copy the WSDL for my service and save it as a .wsdl on my desktop (see WSDL below)
I successfully upload the WSDL to Azure in API Management
When running the HelloWorld function, I get a 500 error. Why is this?
Service.asmx:
Imports System.Web.Services
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://mynamespace.com/")>
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
POST (http://localhost:58904/Service.asmx/HelloWorld) (returns "Hello World")
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<HelloWorld xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mynamespace.com/" />
</Body>
</Envelope>
WSDL
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://mynamespace.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://mynamespace.com/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://mynamespace.com/">
<s:element name="HelloWorld">
<s:complexType/>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld"/>
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse"/>
</wsdl:message>
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn"/>
<wsdl:output message="tns:HelloWorldSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="HelloWorld">
<soap:operation soapAction="http://mynamespace.com/HelloWorld" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="HelloWorld">
<soap12:operation soapAction="http://mynamespace.com/HelloWorld" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address location="https://localhost:44380/Service.asmx"/>
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address location="https://localhost:44380/Service.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Error
Unable to connect to the remote server
BackendConnectionFailure
Failed method: forward-request
I'm attempting to create user accounts for a vendor tool in batches. I asked the vendor how to turn on the MEX for the endpoint for creating a single account and I adjusted the config file accordingly.
I was able to create a service reference, but all I have in Visual Studio is a client and two interfaces. I can't tell how to create a request. The client has an InvokeService method, but it just takes an object.
I replicated the vendors class structure in my code, but then the service didn't like my type. So, I updated the classes to use the vendor's original namespace, but the service still didn't like it.
Type 'life.businessService.baseBusinessDataModel.BusinessRequest' with data contract name 'BusinessRequest:http://schemas.datacontract.org/2004/07/life.businessService.baseBusinessDataModel' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Here's the WSDL from the service. I'm not very strong in WCF, so I'm hoping for some guidance. Thanks!
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ClientWcfBusinessFacadeService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsp:Policy wsu:Id="NetNamedPipeBinding_IWcfBusinessFacade_policy">
<wsp:ExactlyOne>
<wsp:All>
<msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1">
</msb:BinaryEncoding>
<wsaw:UsingAddressing>
</wsaw:UsingAddressing>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="NetTcpBinding_IWcfBusinessFacade_policy">
<wsp:ExactlyOne>
<wsp:All>
<msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1">
</msb:BinaryEncoding>
<wsaw:UsingAddressing>
</wsaw:UsingAddressing>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import namespace="http://tempuri.org/" />
<xsd:import namespace="http://schemas.datacontract.org/2004/07/life.common.serviceCommon" />
<xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="IWcfBusinessFacade_InvokeService_InputMessage">
<wsdl:part name="parameters" element="tns:InvokeService" />
</wsdl:message>
<wsdl:message name="IWcfBusinessFacade_InvokeService_OutputMessage">
<wsdl:part name="parameters" element="tns:InvokeServiceResponse" />
</wsdl:message>
<wsdl:message name="IWcfBusinessFacade_InvokeService_ServiceFaultFault_FaultMessage">
<wsdl:part xmlns:q1="http://schemas.datacontract.org/2004/07/life.common.serviceCommon" name="detail" element="q1:ServiceFault" />
</wsdl:message>
<wsdl:portType name="IWcfBusinessFacade">
<wsdl:operation name="InvokeService">
<wsdl:input wsaw:Action="http://tempuri.org/IWcfBusinessFacade/InvokeService" message="tns:IWcfBusinessFacade_InvokeService_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IWcfBusinessFacade/InvokeServiceResponse" message="tns:IWcfBusinessFacade_InvokeService_OutputMessage" />
<wsdl:fault wsaw:Action="http://tempuri.org/IWcfBusinessFacade/InvokeServiceServiceFaultFault" name="ServiceFaultFault" message="tns:IWcfBusinessFacade_InvokeService_ServiceFaultFault_FaultMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NetNamedPipeBinding_IWcfBusinessFacade" type="tns:IWcfBusinessFacade">
<wsp:PolicyReference URI="#NetNamedPipeBinding_IWcfBusinessFacade_policy">
</wsp:PolicyReference>
<soap12:binding transport="http://schemas.microsoft.com/soap/named-pipe" />
<wsdl:operation name="InvokeService">
<soap12:operation soapAction="http://tempuri.org/IWcfBusinessFacade/InvokeService" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceFaultFault">
<soap12:fault use="literal" name="ServiceFaultFault" namespace="" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NetTcpBinding_IWcfBusinessFacade" type="tns:IWcfBusinessFacade">
<wsp:PolicyReference URI="#NetTcpBinding_IWcfBusinessFacade_policy">
</wsp:PolicyReference>
<soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
<wsdl:operation name="InvokeService">
<soap12:operation soapAction="http://tempuri.org/IWcfBusinessFacade/InvokeService" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceFaultFault">
<soap12:fault use="literal" name="ServiceFaultFault" namespace="" />
<soap12:fault use="literal" name="ServiceFaultFault" namespace="" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ClientWcfBusinessFacadeService">
<wsdl:port name="NetNamedPipeBinding_IWcfBusinessFacade" binding="tns:NetNamedPipeBinding_IWcfBusinessFacade">
<soap12:address location="net.pipe://localhost/WcfBusinessFacadeService" />
<wsa10:EndpointReference>
<wsa10:Address>net.pipe://localhost/WcfBusinessFacadeService</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
<wsdl:port name="NetTcpBinding_IWcfBusinessFacade" binding="tns:NetTcpBinding_IWcfBusinessFacade">
<soap12:address location="net.tcp://localhost:8086/WcfBusinessFacadeService" />
<wsa10:EndpointReference>
<wsa10:Address>net.tcp://localhost:8086/WcfBusinessFacadeService</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
<wsdl:port name="NetTcpBinding_IWcfBusinessFacade1" binding="tns:NetTcpBinding_IWcfBusinessFacade">
<soap12:address location="net.tcp://localhost:10000/WcfBusinessFacadeService" />
<wsa10:EndpointReference>
<wsa10:Address>net.tcp://localhost:10000/WcfBusinessFacadeService</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
For the input message of the InvokeService method, you need to pass the object defined in tns:InvokeService. It will be a type in namespace http://tempuri.org/Imports, but is not explicitly exposed in this WSDL; it is coming from another namespace. You may ask the vendor for the schema XSD or assembly from which this WSDL is expecting to import types below since no absolute or even relative schemaLocation attribute is included
<xsd:import namespace="http://tempuri.org/" />
<xsd:import namespace="http://schemas.datacontract.org/2004/07/life.common.serviceCommon" />
I have the following WSDL file uploaded to Windows Azure Webistes
http://pippogr.azurewebsites.net/ChurchGuideServices.svc?wsdl
Can you tell me what are the values for the Soap_ACtion MEthod name, namespace for the Method: GetMessage
Thanks
You can find it with in binding tag.....
<wsdl:operation name="GetMessage">
<soap:operation soapAction="http://tempuri.org/IChurchGuideServices/GetMessage" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
and Namespace:
xmlns:tns="http://tempuri.org/"
I'm having trouble implementing a service based off of a third-party wsdl. The third-party calls into my service and I can see the data in the trace, but my service parameters keep ending up null after deserialization.
As you can see from the trace, the alertXML node contains a XML document as a string. In the service code, this alertXML string is always null. Is there some special processing I need to do to handle this XML-as-a-string scenario?
Barring that, is there any way for me to just get a hold of the whole envelope so that I can parse the thing out?
Thanks
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2011-07-08T17:46:14.7804786Z" />
<Source Name="System.ServiceModel.MessageLogging" />
<Correlation ActivityID="{54a3d088-5393-45a7-ae97-0bcd636f1750}" />
<Execution ProcessName="w3wp" ProcessID="3468" ThreadID="17" />
<Channel/>
<Computer>COMPUTER</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord Time="2011-07-08T13:46:14.7804786-04:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<HttpRequest>
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Content-Length>1807</Content-Length>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Expect>100-continue</Expect>
<Host>host</Host>
<User-Agent>Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3623)</User-Agent>
<SOAPAction>"http://www.xyz.com/wsdl/ProcessXML"</SOAPAction>
</WebHeaders>
</HttpRequest>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ProcessXML xmlns="http://www.xyz.com/wsdl/">
<alertXml><?xml version="1.0" encoding="UTF-8"?><XMLOutgoing>MORE XML STRING</XMLOutgoing></alertXml>
</ProcessXML>
</soap:Body>
</soap:Envelope>
</MessageLogTraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
EDIT:
The wsdl is:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://www.xyz.com/wsdl/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://www.xyz.com/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.xyz.com/wsdl/">
<s:element name="ProcessXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="alertXml" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ProcessXMLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ProcessXMLResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="ProcessXMLSoapIn">
<wsdl:part name="parameters" element="tns:ProcessXML"/>
</wsdl:message>
<wsdl:message name="ProcessXMLSoapOut">
<wsdl:part name="parameters" element="tns:ProcessXMLResponse"/>
</wsdl:message>
<wsdl:message name="ProcessXMLHttpGetIn">
<wsdl:part name="alertXml" type="s:string"/>
</wsdl:message>
<wsdl:message name="ProcessXMLHttpGetOut">
<wsdl:part name="Body"/>
</wsdl:message>
<wsdl:message name="ProcessXMLHttpPostIn">
<wsdl:part name="alertXml" type="s:string"/>
</wsdl:message>
<wsdl:message name="ProcessXMLHttpPostOut">
<wsdl:part name="Body"/>
</wsdl:message>
<wsdl:portType name="GenericServiceSoap">
<wsdl:operation name="ProcessXML">
<wsdl:input message="tns:ProcessXMLSoapIn"/>
<wsdl:output message="tns:ProcessXMLSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="GenericServiceHttpGet">
<wsdl:operation name="ProcessXML">
<wsdl:input message="tns:ProcessXMLHttpGetIn"/>
<wsdl:output message="tns:ProcessXMLHttpGetOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="GenericServiceHttpPost">
<wsdl:operation name="ProcessXML">
<wsdl:input message="tns:ProcessXMLHttpPostIn"/>
<wsdl:output message="tns:ProcessXMLHttpPostOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="GenericServiceSoap" type="tns:GenericServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ProcessXML">
<soap:operation soapAction="http://www.xyz.com/wsdl/ProcessXML" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="GenericServiceSoap12" type="tns:GenericServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ProcessXML">
<soap12:operation soapAction="http://www.xyz.com/wsdl/ProcessXML" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="GenericServiceHttpGet" type="tns:GenericServiceHttpGet">
<http:binding verb="GET"/>
<wsdl:operation name="ProcessXML">
<http:operation location="/ProcessXML"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:content part="Body" type="text/xml"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="GenericServiceHttpPost" type="tns:GenericServiceHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="ProcessXML">
<http:operation location="/ProcessXML"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:content part="Body" type="text/xml"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GenericService">
</wsdl:service>
</wsdl:definitions>
The skeleton of the service code is:
Public Function ProcessXML(request As ProcessXMLRequest) As ProcessXMLResponse Implements GenericServiceSoap.ProcessXML
'request.Body is a non-null object but request.Body.alertXml is null
End Function
To send XML as a parameter or a property in a DataContract in WCF you need to use XmlElement for the .NET type of the parameter or property. Based on the WSDL in the question, the alertXml will be serialized as a string not XML by WCF. Here is what the WSDL for an XML operation parameter would look like:
<xs:element name="alertXml" nillable="true" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
To see what all the WSDL should look like, implement a service like this:
[ServiceContract]
public interface IService1
{
[OperationContract]
string ProcessXml(XmlElement alertXml);
[OperationContract]
string ProcessSomeXml(ProcessXMLRequest xmlRequest);
}
[DataContract]
public class ProcessXMLRequest
{
public XmlElement someXml { get; set; }
}
//Service implementation
public class Service1 : IService1
{
public string ProcessXml(XmlElement alertXml)
{
XmlNode xmlToProcess = GetXmlToProcess(alertXml);
return string.Format("You entered: {0}", xmlToProcess.InnerText);
}
public string ProcessSomeXml(ProcessXMLRequest xmlRequest)
{
XmlNode xmlToProcess = GetXmlToProcess(xmlRequest.someXml);
return string.Format("You entered some: {0}", xmlToProcess.InnerText);
}
private XmlNode GetXmlToProcess(XmlElement alertXml)
{
var xmlToProcess = alertXml as XmlNode;
if (xmlToProcess == null)
{
var x = new XmlDocument();
x.LoadXml("<root>XML was null</root>");
xmlToProcess = x;
}
return xmlToProcess;
}
}
I have an existing WCF service that works. I've added a reference in Visual Studio 2010 for my Windows Phone app. The reference shows up and I see the methods when I check out the properties of it. The service is using basicHttpBinding. It seems the proxy class is never generated. I cannot reference it (yes - I'm checking the proper namespace)
I'm aware of the SlSvcUtil.exe utility - but that is supposed to not be necessary anymore. Any thoughts as to why my proxy class isn't being generated but the service reference is there?
Thanks!
EDIT: Wsdl file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ProjectManager" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://somesite/ProjectManager/ProjectManager.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://somesite/ProjectManager/ProjectManager.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://somesite/ProjectManager/ProjectManager.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/ProjectManager" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="IProjectManagerService_GetProjectList_InputMessage">
<wsdl:part name="parameters" element="tns:GetProjectList" />
</wsdl:message>
<wsdl:message name="IProjectManagerService_GetProjectList_OutputMessage">
<wsdl:part name="parameters" element="tns:GetProjectListResponse" />
</wsdl:message>
<wsdl:message name="IProjectManagerService_GetProjectFiles_InputMessage">
<wsdl:part name="parameters" element="tns:GetProjectFiles" />
</wsdl:message>
<wsdl:message name="IProjectManagerService_GetProjectFiles_OutputMessage">
<wsdl:part name="parameters" element="tns:GetProjectFilesResponse" />
</wsdl:message>
<wsdl:portType name="IProjectManagerService">
<wsdl:operation name="GetProjectList">
<wsdl:input wsaw:Action="http://tempuri.org/IProjectManagerService/GetProjectList" message="tns:IProjectManagerService_GetProjectList_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IProjectManagerService/GetProjectListResponse" message="tns:IProjectManagerService_GetProjectList_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="GetProjectFiles">
<wsdl:input wsaw:Action="http://tempuri.org/IProjectManagerService/GetProjectFiles" message="tns:IProjectManagerService_GetProjectFiles_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IProjectManagerService/GetProjectFilesResponse" message="tns:IProjectManagerService_GetProjectFiles_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IProjectManagerService" type="tns:IProjectManagerService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetProjectList">
<soap:operation soapAction="http://tempuri.org/IProjectManagerService/GetProjectList" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetProjectFiles">
<soap:operation soapAction="http://tempuri.org/IProjectManagerService/GetProjectFiles" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProjectManager">
<wsdl:port name="BasicHttpBinding_IProjectManagerService" binding="tns:BasicHttpBinding_IProjectManagerService">
<soap:address location="http://somesite/ProjectManager/ProjectManager.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
This has happened to me.
Not sure what causes it.
What works for me is to close down Visual Studio, reopen, right click on the service and click Update Service Reference.
I got exactly the same problem. And installing the "Windows Phone Developer Tools Fix" solved the problem.
Here is the link to download the fix: http://download.microsoft.com/download/6/D/6/6D66958D-891B-4C0E-BC32-2DFC41917B11/VS10-KB2486994-x86.exe
Good luck!
I had this problem.
Adding the service again with another name solved the problem for me once or twice.
Slsvc works every time and is much nicer to work with when checking into TFS.
Not sure if this is TFS related or not.
Oddly enough - a month later it started working with no other installs. Its possible that a recent reboot 'fixed' it but thought I had rebooted prior as well - who knows though. Either way its working.