• 2071阅读
  • 2回复

[提问]怎么写webservice程序 [复制链接]

上一主题 下一主题
离线介农酥
 

只看楼主 倒序阅读 楼主  发表于: 2019-10-09
回复本帖可获得5点威望奖励!
每人最多可获奖3次,奖池剩余20点威望 (中奖几率80%)
因为项目有点急,网上看了下,还是很多东西不懂,所以直接开问,望各位大力支持

客户将数据发给我,我来接受,所以我这边应该属于服务端。

我这边应该怎么写呢?我自己是这样写的,打个比方:
1)写好约定好的函数名,如在class.cpp文件中写:
void getCZYB(QString str);
2)在wsdl.xml文件中添加该函数的信息(乱写的,大家理解就行)
?xml version="1.0" encoding="UTF-8" ?
definitions name="FooSample"
 targetNamespace="http://tempuri.org/wsdl/"
 xmlns:wsdlns="http://tempuri.org/wsdl/"
 xmlns:typens="http://tempuri.org/xsd"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extension"
 xmlns="http://schemas.xmlsoap.org/wsdl/"

types
schema targetNamespace="http://tempuri.org/xsd"
  xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  elementFormDefault="qualified"
/schema
/types

message name="Simple.getCZYB"//函数名getCZYB
 <part name="str" type="xsd:int"///输入参数str,类型string
/message


portType name="SimplePortType"
 <operation name="getCZYB" parameterOrder="str"
  <input message="wsdlns:Simple.getCZYB"///输入
 </operation
/portType

binding name="SimpleBinding" type="wsdlns:SimplePortType"
 <stk:binding preferredEncoding="UTF-8" /
 <soap:binding style="rpc"
  transport="http://schemas.xmlsoap.org/soap/http"/
 <operation name="getCZYB"
  <soap:operation soapAction="http://tempuri.org/action/Simple.getCZYB"/
  <input
   <soap:body use="encoded" namespace="http://tempuri.org/message/"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /
  </input
 </operation
/binding

service name="FOOSAMPLEService"
 <port name="SimplePort" binding="wsdlns:SimpleBinding"
  <soap:address location="http://carlos:8080/FooSample/FooSample.asp"/
 </port
/service
/definitions


1)我现在不太明白的时,这个WSDL文件是谁提供的,客户端还是服务端(其实我的程序应该既要做客户端,又要做服务端)。
2)服务端需要监听客户端,这个监听就是http(QT直接用tcpSocket)监听吗?监听的地址是什么,wsdl文件的地址吗?
3)我的代码如何与wsdl文件关联。
服务端如何写?
我的理解是1. 写cpp程序,2)写wsdl文件,3)将cpp和wsdl关联起来
在线uidab

只看该作者 1楼 发表于: 2019-10-09
回帖奖励+ 5
https://blog.csdn.net/zhangyuanxuevaq/article/details/79687441
https://baijiahao.baidu.com/s?id=1626040867645963860&wfr=spider&for=pc

多百度一下,一般只需用命令生成一下,Qt即可调用,和调用普通C++接口没什么区别。

越急越做不好。
有时候为了工作直接获得答案,而我却失去了思考的乐趣!


飘啊飘,何时能安居!
离线介农酥

只看该作者 2楼 发表于: 2019-10-09
回 uidab 的帖子
uidab:https://blog.csdn.net/zhangyuanxuevaq/article/details/79687441
https://baijiahao.baidu.com/s?id=1626040867645963860&wfr=spider&for=pc
多百度一下,一般只需用命令生成一下,Qt即可调用,和调用普通C++接口没什么区别。
....... (2019-10-09 16:39) 

看懂了,,非常非常感谢!
快速回复
限100 字节
 
上一个 下一个